package net.xiduth.net.decoders.handlers;

import net.xiduth.Settings;
import net.xiduth.cache.loaders.ObjectDefinitions;
import net.xiduth.game.Animation;
import net.xiduth.game.ForceMovement;
import net.xiduth.game.Graphics;
import net.xiduth.game.World;
import net.xiduth.game.WorldObject;
import net.xiduth.game.WorldTile;
import net.xiduth.game.item.Item;
import net.xiduth.game.minigames.CastleWars;
import net.xiduth.game.minigames.Crucible;
import net.xiduth.game.minigames.FightPits;
import net.xiduth.game.minigames.PestControl;
import net.xiduth.game.player.ClueScrolls;
import net.xiduth.game.player.CoordsEvent;
import net.xiduth.game.player.OwnedObjectManager;
import net.xiduth.game.player.Player;
import net.xiduth.game.player.QuestManager.Quests;
import net.xiduth.game.player.Skills;
import net.xiduth.game.player.actions.Bonfire;
import net.xiduth.game.player.actions.BoxAction.HunterEquipment;
import net.xiduth.game.player.actions.BoxAction.HunterNPC;
import net.xiduth.game.player.actions.Cooking;
import net.xiduth.game.player.actions.Cooking.Cookables;
import net.xiduth.game.player.actions.CowMilkingAction;
import net.xiduth.game.player.actions.Farming;
import net.xiduth.game.player.actions.Farming.Allotments;
import net.xiduth.game.player.actions.Farming.Flowers;
import net.xiduth.game.player.actions.Farming.Trees;
import net.xiduth.game.player.actions.LavaFlowMine;
import net.xiduth.game.player.actions.Smithing.ForgingBar;
import net.xiduth.game.player.actions.Smithing.ForgingInterface;
import net.xiduth.game.player.actions.Summoning;
import net.xiduth.game.player.actions.Woodcutting;
import net.xiduth.game.player.actions.Woodcutting.TreeDefinitions;
import net.xiduth.game.player.actions.altar.BonesOnAltar;
import net.xiduth.game.player.actions.altar.BonesOnAltar.Bones;
import net.xiduth.game.player.actions.mining.EssenceMining;
import net.xiduth.game.player.actions.mining.EssenceMining.EssenceDefinitions;
import net.xiduth.game.player.actions.mining.Mining;
import net.xiduth.game.player.actions.mining.Mining.RockDefinitions;
import net.xiduth.game.player.actions.mining.MiningBase;
import net.xiduth.game.player.actions.runecrafting.SihponActionNodes;
import net.xiduth.game.player.actions.sandstone.RedSandStone;
import net.xiduth.game.player.actions.sandstone.RedSandStone.Sandstone;
import net.xiduth.game.player.actions.thieving.Thieving;
import net.xiduth.game.player.combat.PlayerCombat;
import net.xiduth.game.player.content.CrystalChest;
import net.xiduth.game.player.content.DonatorZone;
import net.xiduth.game.player.content.Hunter;
import net.xiduth.game.player.content.Magic;
import net.xiduth.game.player.content.PartyRoom;
import net.xiduth.game.player.content.PolyporeDungeon;
import net.xiduth.game.player.content.RCObelisks;
import net.xiduth.game.player.content.ResourceDungeons;
import net.xiduth.game.player.content.Runecrafting;
import net.xiduth.game.player.content.RoguesDen;
import net.xiduth.game.player.content.ShootingStar;
import net.xiduth.game.player.content.UnlitBeacon;
import net.xiduth.game.player.content.agility.AdvancedGnomeAgility;
import net.xiduth.game.player.content.agility.BarbarianOutpostAgility;
import net.xiduth.game.player.content.agility.GnomeAgility;
import net.xiduth.game.player.content.agility.WildernessAgility;
import net.xiduth.game.player.content.artisan.ArtisanWorkshop;
import net.xiduth.game.player.content.citadels.Portal;
import net.xiduth.game.player.content.construction.Furniture;
import net.xiduth.game.player.content.events.objects.AncientTempleHandler;
import net.xiduth.game.player.content.events.objects.BossCaveHandler;
import net.xiduth.game.player.content.events.objects.ElementRiftHandler;
import net.xiduth.game.player.content.livid.LividFarm;
import net.xiduth.game.player.controlers.Falconry;
import net.xiduth.game.player.controlers.FightCaves;
import net.xiduth.game.player.controlers.FightKiln;
import net.xiduth.game.player.controlers.NomadsRequiem;
import net.xiduth.game.player.controlers.WGuildControler;
import net.xiduth.game.player.controlers.Wilderness;
import net.xiduth.game.player.dialogues.MiningGuildDwarf;
import net.xiduth.game.tasks.WorldTask;
import net.xiduth.game.tasks.WorldTasksManager;
import net.xiduth.io.InputStream;
import net.xiduth.utils.FairyRing;
import net.xiduth.utils.Logger;
import net.xiduth.utils.PkRank;
import net.xiduth.utils.Utils;

public final class ObjectHandler {

	private ObjectHandler() {

	}

	public static void handleOption(final Player player, InputStream stream,
			int option) {
		if (!player.hasStarted() || !player.clientHasLoadedMapRegion()
				|| player.isDead())
			return;
		long currentTime = Utils.currentTimeMillis();
		if (player.getLockDelay() >= currentTime
				|| player.getEmotesManager().getNextEmoteEnd() >= currentTime)
			return;
		boolean forceRun = stream.readUnsignedByte128() == 1;
		final int id = stream.readIntLE();
		int x = stream.readUnsignedShortLE();
		int y = stream.readUnsignedShortLE128();
		int rotation = 0;
		if (player.isAtDynamicRegion()) {
			rotation = World.getRotation(player.getPlane(), x, y);
			if (rotation == 1) {
				ObjectDefinitions defs = ObjectDefinitions
						.getObjectDefinitions(id);
				y += defs.getSizeY() - 1;
			} else if (rotation == 2) {
				ObjectDefinitions defs = ObjectDefinitions
						.getObjectDefinitions(id);
				x += defs.getSizeY() - 1;
			}
		}
		final WorldTile tile = new WorldTile(x, y, player.getPlane());
		final int regionId = tile.getRegionId();
		if (!player.getMapRegionsIds().contains(regionId))
			return;
		WorldObject mapObject = World.getRegion(regionId).getObject(id, tile);
		if (mapObject == null || mapObject.getId() != id)
			return;
		if (player.isAtDynamicRegion()
				&& World.getRotation(player.getPlane(), x, y) != 0) { // temp
																		// fix
			ObjectDefinitions defs = ObjectDefinitions.getObjectDefinitions(id);
			if (defs.getSizeX() > 1 || defs.getSizeY() > 1) {
				for (int xs = 0; xs < defs.getSizeX() + 1
						&& (mapObject == null || mapObject.getId() != id); xs++) {
					for (int ys = 0; ys < defs.getSizeY() + 1
							&& (mapObject == null || mapObject.getId() != id); ys++) {
						tile.setLocation(x + xs, y + ys, tile.getPlane());
						mapObject = World.getRegion(regionId).getObject(id,
								tile);
					}
				}
			}
			if (mapObject == null || mapObject.getId() != id)
				return;
		}
		final WorldObject object = !player.isAtDynamicRegion() ? mapObject
				: new WorldObject(id, mapObject.getType(),
						(mapObject.getRotation() + rotation % 4), x, y,
						player.getPlane());
		player.stopAll(false);
		if (forceRun)
			player.setRun(forceRun);
		switch (option) {
		case 1:
			handleOption1(player, object);
			break;
		case 2:
			handleOption2(player, object);
			break;
		case 3:
			handleOption3(player, object);
			break;
		case 4:
			handleOption4(player, object);
			break;
		case 5:
			handleOption5(player, object);
			break;
		case -1:
			handleOptionExamine(player, object);
			break;
		}
	}

	private static void handleOption1(final Player player,
			final WorldObject object) {
		final ObjectDefinitions objectDef = object.getDefinitions();
		final int id = object.getId();
		final int x = object.getX();
		final int y = object.getY();
		int destX = player.getX();
		int destY = player.getY();
		if (id == 43529 && destX >= 2484 && destY >= 3417 && destX <= 2487
				&& destY <= 3422 && player.getPlane() == 3)
			AdvancedGnomeAgility.PreSwing(player, object);
		else if (SihponActionNodes.siphon(player, object))
			return;
		player.setCoordsEvent(new CoordsEvent(object, new Runnable() {
			@Override
			public void run() {
				player.stopAll();
				player.faceObject(object);
				if (!player.getControlerManager().processObjectClick1(object))
					return;
				if (CastleWars.handleObjects(player, id))
					return;
				if (RoguesDen.handleObjects(player, id))
					return;
				if (ResourceDungeons.handleObjects(player, id))
					return;
				if (object.getId() == 19205)
					Hunter.createLoggedObject(player, object, true);
				HunterNPC hunterNpc = HunterNPC.forObjectId(id);
				if (object.getId() == 38453) {
					player.getDialogueManager().startDialogue("SimpleMessage",
							"Use your logs on this for extra xp and gold!");
				}
				if (id == 2562) {
					player.getDialogueManager().startDialogue("MuseumGuard");
				}
				/**
				 * 
				 * Essential objects for Godwars, etc.
				 * 
				 */
				switch (object.getId()) {
				case 1317:
				case 68973:
					player.getDialogueManager().startDialogue("SpiritTreeDialogue", object.getId());
					break;
				case 68974:
					player.getDialogueManager().startDialogue("MainSpiritTreeDialogue", object.getId());
					break;
				case 26425:
					if (player.getBandos() < 20) {
						player.getPackets()
								.sendGameMessage(
										"You need a Bandos killcount of at least 20 to enter this room.");
						return;
					} else if (player.getBandos() >= 20) {
						player.move(new WorldTile(2864, 5354, 2));
						player.resetBandos();
					}
					break;
				case 26428:
					if (player.getZamorakKC() < 20) {
						player.getPackets()
								.sendGameMessage(
										"You need a Zamorak killcount of at least 20 to enter this room.");
						return;
					} else if (player.getZamorakKC() >= 20) {
						player.move(new WorldTile(2925, 5331, 2));
						player.resetZamorakKC();
					}
					break;
				case 26427:
					if (player.getSaradominKC() < 20) {
						player.getPackets()
								.sendGameMessage(
										"You need a Saradomin killcount of at least 20 to enter this room.");
						return;
					} else if (player.getSaradominKC() >= 20) {
						player.move(new WorldTile(2907, 5265, 0));
						player.resetSaradominKC();
					}
					break;
				case 26426:
					if (player.getArmadylKC() < 20) {
						player.getPackets()
								.sendGameMessage(
										"You need an Armadyl killcount of at least 20 to enter this room.");
						return;
					} else if (player.getArmadylKC() >= 20) {
						player.move(new WorldTile(2839, 5296, 2));
						player.resetArmadyl();
					}
					break;
				case 26444:
					player.move(new WorldTile(2916, 5300, 1));
					break;
				case 26445:
					player.move(new WorldTile(2918, 5274, 0));
					break;
				case 57225:
					player.getDialogueManager().startDialogue("NexEntrance");
					break;
				case 26303:
					player.getDialogueManager().startDialogue("GrapplePillar");
					break;
				case 57211:
					player.getDialogueManager().startDialogue("FrozenDoor");
					break;
				case 57254:
					player.getDialogueManager().startDialogue("Hole");
					break;
				case 2909:
				case 2908:
					player.getDialogueManager().startDialogue("LucienFire");
					break;
				}
				if (id == 2564) {
					player.getDialogueManager().startDialogue("MuseumGuard2");
				}
				if (id == 59463) {
					Portal.checkCitadel(player);
				}
				if (object.getId() == 13405) {
					player.getDialogueManager().startDialogue("LeaveHouse");
				}
				if (object.getId() == 11211) {
					if (player.isDonator() || player.isExtremeDonator()
							|| player.isExtremePermDonator()
							|| player.isSuperDonator()
							|| player.isSuperPermDonator()) {
						DonatorZone.enterDonatorzone(player);
					}
				}
				if (ClueScrolls.objectSpot(player, object)) {
					return;
				}
				if (id == 8135) {
					player.getDialogueManager().startDialogue("HerbSeeds");
				}
				/**
				 * Construction Teleport Portals
				 */

				switch (object.getId()) {
				case 13622: // Varrock
					Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(
							3213, 3428, 0));
					break;
				case 13623: // Lumbridge
					Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(
							3222, 3219, 0));
					break;
				case 13624: // Falador
					Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(
							2965, 3380, 0));
					break;
				case 13625: // Camelot
					Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(
							2726, 3485, 0));
					break;
				case 13627: // Yanille
					Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(
							2606, 3092, 0));
					break;
				case 13613:
					if (!player.getInventory().containsItem(590, 1)) {
						player.out("You need a tinder box to light the fireplace.");
					} else {
						player.firePlace = 6;
						player.out("You light the fire place.");
					}
					break;
				case 13611:
					if (!player.getInventory().containsItem(590, 1)) {
						player.out("You need a tinder box to light the fireplace.");
					} else {
						player.firePlace = 5;
						player.out("You light the fire place.");
					}
					break;
				case 13609:
					if (!player.getInventory().containsItem(590, 1)) {
						player.out("You need a tinder box to light the fireplace.");
					} else {
						player.firePlace = 4;
						player.out("You light the fire place.");
					}
					break;
				}

				switch (objectDef.name.toLowerCase()) {
				case "chair":
					if (id == 13581) {
						player.out("This chair may break if I were to sit on it.");
						break;
					}
					Furniture.sitInChair(object, player);
					player.faceObject(object);
				case "throne":
					Furniture.sitInChair(object, player);
					break;
				}
				if (id == 70794) {
					player.setNextWorldTile(new WorldTile(1340, 6488, 0));
				} else if (id == 70796)
					player.setNextWorldTile(new WorldTile(1090, 6360, 0));
				else if (id == 70797)
					player.setNextWorldTile(new WorldTile(1090, 6597, 0));
				else if (id == 70798)
					player.setNextWorldTile(new WorldTile(1340, 6497, 0));
				else if (id == 70799) {
					if (player.getSkills().getLevelForXp(Skills.AGILITY) < 60) {
						player.getPackets()
								.sendGameMessage(
										"You need an Agility level of 60 to use this shorcut.");
						return;
					}
					player.setNextWorldTile(new WorldTile(1178, 6356, 0));
				} else if (id == 70795) {
					if (player.getSkills().getLevelForXp(Skills.AGILITY) < 60) {
						player.getPackets()
								.sendGameMessage(
										"You need an Agility level of 60 to use this shorcut.");
						return;
					}
					player.getDialogueManager().startDialogue(
							"GrotDungeonAgility");
				}

				/**
				 * 
				 * Teleport portal. wat
				 */
				if (id == 45009) {
					Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(
							4521, 5651, 0));
				}

				if (id == 45008) {
					Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(
							4521, 5651, 0));
				}

				if (id == 11899) {
					player.getDialogueManager()
							.startDialogue("TeleportCrystal");
				}
				if (id == 29395) {
					player.getInterfaceManager().sendInterface(
							ArtisanWorkshop.INGOTWITH);
					if (id == 29394) {
						player.getInterfaceManager().sendInterface(
								ArtisanWorkshop.INGOTWITH);
					}
					if (id == 40443) {
						LividFarm.deposit(player);
					}
				}
				if (id == 29396) {
					ArtisanWorkshop.DepositArmour(player);
					player.getInventory().refresh();
				}
				if (id == 2406) {
					if (player.getEquipment().getWeaponId() == 772
							&& player.spokeToWarrior == true
							&& player.spokeToShamus == true
							&& player.spokeToMonk == true) {
						player.setNextWorldTile(new WorldTile(2383, 4458,
								player.getPlane()));
						player.lostCity();
					}
				}
				if (id == 24821) {
					ArtisanWorkshop.GiveBronzeIngots(player);
				}
				if (id == 24822) {
					ArtisanWorkshop.GiveIronIngots(player);
				}
				if (id == 24823) {
					ArtisanWorkshop.GiveSteelIngots(player);
				}
				if (id == 40492) {
					LividFarm.MakePlants(player);
				}
				if (id == 40486) {
					LividFarm.MakePlants(player);
				}
				if (id == 40505) {
					LividFarm.MakePlants(player);
				}
				if (id == 40534) {
					LividFarm.MakePlants(player);
				}
				if (id == 40464) {
					LividFarm.MakePlants(player);
				}
				if (id == 40489) {
					LividFarm.MakePlants(player);
				}
				if (id == 40487) {
					LividFarm.MakePlants(player);
				}
				if (id == 40532) {
					LividFarm.MakePlants(player);
				}
				if (id == 40499) {
					LividFarm.MakePlants(player);
				}
				if (id == 40533) {
					LividFarm.MakePlants(player);
				}
				if (id == 40504) {
					LividFarm.MakePlants(player);
				}

				/**
				 * 
				 * Multicannon firing.
				 * 
				 */
				if (id == 29408) {
					player.getRoyaleDwarfCannon().preRotationSetup(object);
				}
				if (id == 6) {
					player.getDwarfCannon().preRotationSetup(object);
				}
				if (id == 29406) {
					player.getGoldDwarfCannon().preRotationSetup(object);
				}
				if (id == 37985) {
					player.getControlerManager().startControler("funzone");
					player.setNextAnimation(new Animation(645));
					int maxPrayer = player.getSkills().getLevelForXp(
							Skills.PRAYER) * 10;
					player.getPrayer().restorePrayer(maxPrayer);
					player.heal(player.getHitpoints() * 10);
					player.getPackets().sendGameMessage(
							"You feel refreshed...", true);
					;
				}

				/**
				 * 
				 * Falador partyroom
				 * 
				 * 
				 */
				if (id == 26194) {
					player.getDialogueManager().startDialogue("PartyRoomLever");
				}
				if (id == 115 && object.getX() == 3049 && object.getY() == 3381) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3049, 3381,
							0), true);
				}
				if (id == 116 && object.getX() == 3045 && object.getY() == 3380) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3045, 3380,
							0), true);
				}
				if (id == 117 && object.getX() == 3043 && object.getY() == 3383) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3043, 3383,
							0), true);
				}
				if (id == 118 && object.getX() == 3041 && object.getY() == 3380) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3041, 3380,
							0), true);
				}
				if (id == 119 && object.getX() == 3039 && object.getY() == 3378) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3039, 3378,
							0), true);
				}
				if (id == 120 && object.getX() == 3041 && object.getY() == 3377) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3041, 3377,
							0), true);
				}
				if (id == 121 && object.getX() == 3041 && object.getY() == 3376) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3041, 3376,
							0), true);
				}
				if (id == 122 && object.getX() == 3042 && object.getY() == 3373) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3042, 3373,
							0), true);
				}
				if (id == 115 && object.getX() == 3045 && object.getY() == 3376) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3045, 3376,
							0), true);
				}
				if (id == 116 && object.getX() == 3046 && object.getY() == 3375) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3046, 3375,
							0), true);
				}
				if (id == 117 && object.getX() == 3049 && object.getY() == 3376) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3049, 3376,
							0), true);
				}
				if (id == 118 && object.getX() == 3052 && object.getY() == 3378) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3052, 3378,
							0), true);
				}
				if (id == 119 && object.getX() == 3050 && object.getY() == 3379) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3050, 3379,
							0), true);
				}
				if (id == 120 && object.getX() == 3046 && object.getY() == 3382) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3046, 3382,
							0), true);
				}
				if (id == 121 && object.getX() == 3044 && object.getY() == 3377) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3044, 3377,
							0), true);
				}
				if (id == 122 && object.getX() == 3043 && object.getY() == 3375) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3043, 3375,
							0), true);
				}
				if (id == 115 && object.getX() == 3047 && object.getY() == 3374) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3047, 3374,
							0), true);
				}
				if (id == 116 && object.getX() == 3050 && object.getY() == 3374) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3050, 3374,
							0), true);
				}
				if (id == 117 && object.getX() == 3051 && object.getY() == 3377) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3051, 3377,
							0), true);
				}
				if (id == 118 && object.getX() == 3047 && object.getY() == 3379) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3047, 3379,
							0), true);
				}
				if (id == 119 && object.getX() == 3048 && object.getY() == 3382) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3048, 3382,
							0), true);
				}
				if (id == 120 && object.getX() == 3045 && object.getY() == 3383) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3045, 3383,
							0), true);
				}
				if (id == 121 && object.getX() == 3043 && object.getY() == 3381) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3043, 3381,
							0), true);
				}
				if (id == 122 && object.getX() == 3039 && object.getY() == 3380) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3039, 3380,
							0), true);
				}
				if (id == 115 && object.getX() == 3041 && object.getY() == 3378) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3041, 3378,
							0), true);
				}
				if (id == 116 && object.getX() == 3038 && object.getY() == 3374) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3038, 3374,
							0), true);
				}
				if (id == 117 && object.getX() == 3040 && object.getY() == 3377) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3040, 3377,
							0), true);
				}
				if (id == 118 && object.getX() == 3041 && object.getY() == 3374) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3041, 3374,
							0), true);
				}
				if (id == 119 && object.getX() == 3047 && object.getY() == 3377) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3047, 3377,
							0), true);
				}
				if (id == 120 && object.getX() == 3045 && object.getY() == 3382) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3045, 3382,
							0), true);
				}
				if (id == 121 && object.getX() == 3050 && object.getY() == 3383) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3050, 3383,
							0), true);
				}
				if (id == 122 && object.getX() == 3051 && object.getY() == 3380) {
					player.setNextAnimation(new Animation(794));
					player.getPackets().sendSound(279, 0, 1);
					World.spawnObject(new WorldObject(123, 10, 0, 3051, 3380,
							0), true);
				}

				/**
				 * 
				 * Port Sarim gangplank.
				 * 
				 * 
				 */
				if (id == 14304) {
					player.getDialogueManager()
							.startDialogue("TeleportCrystal");
				}
				if (id == 15482) {
					player.getDialogueManager().startDialogue("HouseTeleport");
				}
				if (id == 170) {
					CrystalChest.openChest(player);
				}
				if (id == 7137) {
					Runecrafting.enterWaterAltar(player);
				}
				if (id == 69831) { // Burthorpe
					player.getPackets().sendConfigByFile(10902, 1);
					if (player.activatedBurthorpeLodestone == false) {
						player.activatedBurthorpeLodestone = true;
					}
				}
				if (id == 69828) { // Lunar Isle
					player.getPackets().sendConfigByFile(2448, 190);
					if (player.activatedLunarIsleLodestone == false) {
						player.activatedLunarIsleLodestone = true;
					}
				}
				if (id == 69827) { // Bandit Camp
					player.getPackets().sendConfigByFile(358, 15);
					if (player.activatedBanditCampLodestone == false) {
						player.activatedBanditCampLodestone = true;
					}
				}
				if (id == 69829) { // Al Kharid
					player.getPackets().sendConfigByFile(10900, 1);
					if (player.activatedAlKharidLodestone == false) {
						player.activatedAlKharidLodestone = true;
					}
				}
				if (id == 69839) { // Taverly
					player.getPackets().sendConfigByFile(10910, 1);
					if (player.activatedTaverlyLodestone == false) {
						player.activatedTaverlyLodestone = true;
					}
				}
				if (id == 69840) { // Varrock
					player.getPackets().sendConfigByFile(10911, 1);
					if (player.activatedVarrockLodestone == false) {
						player.activatedVarrockLodestone = true;
					}
				}
				if (id == 69834) { // Edgeville
					player.getPackets().sendConfigByFile(10905, 1);
					if (player.activatedEdgevilleLodestone == false) {
						player.activatedEdgevilleLodestone = true;
					}
				}
				if (id == 69835) { // Falador
					player.getPackets().sendConfigByFile(10906, 1);
					if (player.activatedFaladorLodestone == false) {
						player.activatedFaladorLodestone = true;
					}
				}
				if (id == 69837) { // Port Sarim
					player.getPackets().sendConfigByFile(10908, 1);
					if (player.activatedPortSarimLodestone == false) {
						player.activatedPortSarimLodestone = true;
					}
				}
				if (id == 69833) { // Draynor
					player.getPackets().sendConfigByFile(10904, 1);
					if (player.activatedDraynorLodestone == false) {
						player.activatedDraynorLodestone = true;
					}
				}
				if (id == 69830) { // Ardougne
					player.getPackets().sendConfigByFile(10901, 1);
					if (player.activatedArdougneLodestone == false) {
						player.activatedArdougneLodestone = true;
					}
				}
				if (id == 69832) { // Catherby
					player.getPackets().sendConfigByFile(10903, 1);
					if (player.activatedCatherbyLodestone == false) {
						player.activatedCatherbyLodestone = true;
					}
				}
				if (id == 69841) { // Yanille
					player.getPackets().sendConfigByFile(10912, 1);
					if (player.activatedYanilleLodestone == false) {
						player.activatedYanilleLodestone = true;
					}
				}
				if (id == 69838) { // Seers' Village
					player.getPackets().sendConfigByFile(10909, 1);
					if (player.activatedSeersVillageLodestone == false) {
						player.activatedSeersVillageLodestone = true;
					}
				}
				if (id == 28716 || id == 67036) {
					Summoning.infusePouches(player);
					player.setNextFaceWorldTile(object);
					return;
				}

				/**
				 * Falador
				 */

				// Flower
				if (id == 7847 && !player.getFaladorFlowerPatchRaked()) {
					Farming.startRake(player, id);
				}

				// North
				if (id == 8550 && !player.getFaladorNorthAllotmentPatchRaked()) {
					Farming.startRake(player, id);
				}

				// South
				if (id == 8551 && !player.getFaladorSouthAllotmentPatchRaked()) {
					Farming.startRake(player, id);
				}

				// North
				if (id == 8550 && player.getFaladorNorthAllotmentPatchRaked()) {
					Farming.harvestAllotment(player, id,
							player.getFaladorNorthAllotmentPatch());
				}

				// South
				if (id == 8551 && player.getFaladorSouthAllotmentPatchRaked()) {
					Farming.harvestAllotment(player, id,
							player.getFaladorSouthAllotmentPatch());
				}

				// Flower
				if (id == 7847 && player.getFaladorFlowerPatchRaked()) {
					Farming.harvestFlower(player, id,
							player.getFaladorFlowerPatch());
				}

				/**
				 * Catherby
				 */
				// Herb
				if (id == 8151 && !player.getCatherbyHerbPatchRaked()) {
					Farming.startRake(player, id);
				}
				// Flower
				if (id == 7848 && !player.getCatherbyFlowerPatchRaked()) {
					Farming.startRake(player, id);
				}

				// North
				if (id == 8552 && !player.getCatherbyNorthAllotmentPatchRaked()) {
					Farming.startRake(player, id);
				}

				// South
				if (id == 8553 && !player.getCatherbySouthAllotmentPatchRaked()) {
					Farming.startRake(player, id);
				}

				// North
				if (id == 8552 && player.getCatherbyNorthAllotmentPatchRaked()) {
					Farming.harvestAllotment(player, id,
							player.getCatherbyNorthAllotmentPatch());
				}

				// South
				if (id == 8553 && player.getCatherbySouthAllotmentPatchRaked()) {
					Farming.harvestAllotment(player, id,
							player.getCatherbySouthAllotmentPatch());
				}
				// Herb
				if (id == 8151 && player.getCatherbyHerbPatchRaked()) {
					Farming.harvestHerb(player, id,
							player.getCatherbyHerbPatch());
				}
				// Flower
				if (id == 7848 && player.getCatherbyFlowerPatchRaked()) {
					Farming.harvestFlower(player, id,
							player.getCatherbyFlowerPatch());
				}

				/**
				 * Ardougne
				 */

				// Flower
				if (id == 7849 && !player.getArdougneFlowerPatchRaked()) {
					Farming.startRake(player, id);
				}

				// North
				if (id == 8554 && !player.getArdougneNorthAllotmentPatchRaked()) {
					Farming.startRake(player, id);
				}

				// South
				if (id == 8555 && !player.getArdougneSouthAllotmentPatchRaked()) {
					Farming.startRake(player, id);
				}

				// North
				if (id == 8554 && player.getArdougneNorthAllotmentPatchRaked()) {
					Farming.harvestAllotment(player, id,
							player.getArdougneNorthAllotmentPatch());
				}

				// South
				if (id == 8555 && player.getArdougneSouthAllotmentPatchRaked()) {
					Farming.harvestAllotment(player, id,
							player.getArdougneSouthAllotmentPatch());
				}

				// Flower
				if (id == 7849 && player.getArdougneFlowerPatchRaked()) {
					Farming.harvestFlower(player, id,
							player.getArdougneFlowerPatch());
				}

				/**
				 * Canifis
				 */

				// Flower
				if (id == 7850 && !player.getCanifisFlowerPatchRaked()) {
					Farming.startRake(player, id);
				}

				// North
				if (id == 8556 && !player.getCanifisNorthAllotmentPatchRaked()) {
					Farming.startRake(player, id);
				}

				// South
				if (id == 8557 && !player.getCanifisSouthAllotmentPatchRaked()) {
					Farming.startRake(player, id);
				}

				// North
				if (id == 8556 && player.getCanifisNorthAllotmentPatchRaked()) {
					Farming.harvestAllotment(player, id,
							player.getCanifisNorthAllotmentPatch());
				}

				// South
				if (id == 8557 && player.getCanifisSouthAllotmentPatchRaked()) {
					Farming.harvestAllotment(player, id,
							player.getCanifisSouthAllotmentPatch());
				}

				// Flower
				if (id == 7850 && player.getCanifisFlowerPatchRaked()) {
					Farming.harvestFlower(player, id,
							player.getCanifisFlowerPatch());
				}

				/**
				 * Lumbridge
				 */

				// Tree Patch
				if (id == 8391 && !player.getLummyTreePatchRaked()) {
					Farming.startRake(player, id);
				}

				// Tree Patch
				if (id == 8391 && player.getLummyTreePatchRaked()) {
					Farming.harvestTreeSapling(player, id,
							player.getLummyTreePatch());
				}

				/**
				 * Varrock
				 */

				// Tree Patch
				if (id == 8390 && !player.getVarrockTreePatchRaked()) {
					Farming.startRake(player, id);
				}

				// Tree Patch
				if (id == 8390 && player.getVarrockTreePatchRaked()) {
					Farming.harvestTreeSapling(player, id,
							player.getVarrockTreePatch());
				}

				/**
				 * Falador
				 */

				// Tree Patch
				if (id == 8389 && !player.getFaladorTreePatchRaked()) {
					Farming.startRake(player, id);
				}

				// Tree Patch
				if (id == 8389 && player.getFaladorTreePatchRaked()) {
					Farming.harvestTreeSapling(player, id,
							player.getFaladorTreePatch());
				}

				/**
				 * Taverly
				 */

				// Tree Patch
				if (id == 8388 && !player.getTaverlyTreePatchRaked()) {
					Farming.startRake(player, id);
				}

				// Tree Patch
				if (id == 8388 && player.getTaverlyTreePatchRaked()) {
					Farming.harvestTreeSapling(player, id,
							player.getTaverlyTreePatch());
				}

				if (id == 29958 || id == 4019 || id == 50205 || id == 50206
						|| id == 50207 || id == 53883 || id == 54650
						|| id == 55605 || id == 56083 || id == 56084
						|| id == 56085 || id == 56086) {
					final int maxSummoning = player.getSkills().getLevelForXp(
							23);
					if (player.getSkills().getLevel(23) < maxSummoning) {
						player.lock(5);
						player.getPackets().sendGameMessage(
								"You feel the obelisk", true);
						player.setNextAnimation(new Animation(8502));
						player.setNextGraphics(new Graphics(1308));
						WorldTasksManager.schedule(new WorldTask() {

							@Override
							public void run() {
								player.getSkills().restoreSummoning();
								player.getPackets().sendGameMessage(
										"...and recharge all your skills.",
										true);
							}
						}, 2);
					} else {
						player.getPackets().sendGameMessage(
								"You already have full summoning.", true);
					}
					return;
				}
				if (hunterNpc != null) {
					if (OwnedObjectManager.removeObject(player, object)) {
						player.setNextAnimation(hunterNpc.getEquipment()
								.getPickUpAnimation());
						player.getInventory().getItems()
								.addAll(hunterNpc.getItems());
						player.getInventory().addItem(
								hunterNpc.getEquipment().getId(), 1);
						player.getSkills().addXp(Skills.HUNTER,
								hunterNpc.getXp());
					} else {
						player.getPackets().sendGameMessage(
								"This isn't your trap.");
					}
				} else if (id == HunterEquipment.BOX.getObjectId()
						|| id == 19192) {
					if (OwnedObjectManager.removeObject(player, object)) {
						player.setNextAnimation(new Animation(5208));
						player.getInventory().addItem(
								HunterEquipment.BOX.getId(), 1);
					} else
						player.getPackets().sendGameMessage(
								"This isn't your trap.");
				} else if (id == HunterEquipment.BRID_SNARE.getObjectId()
						|| id == 19174) {
					if (OwnedObjectManager.removeObject(player, object)) {
						player.setNextAnimation(new Animation(5207));
						player.getInventory().addItem(
								HunterEquipment.BRID_SNARE.getId(), 1);
					} else
						player.getPackets().sendGameMessage(
								"This isn't your trap.");
				} else if (id == 2350
						&& (object.getX() == 3352 && object.getY() == 3417 && object
								.getPlane() == 0))
					player.useStairs(832, new WorldTile(3177, 5731, 0), 1, 2);
				else if (id == 2353
						&& (object.getX() == 3177 && object.getY() == 5730 && object
								.getPlane() == 0))
					player.useStairs(828, new WorldTile(3353, 3416, 0), 1, 2);
				else if (id == 11554 || id == 11552)
					player.getPackets().sendGameMessage(
							"That rock is currently unavailable.");
				else if (id == 38279)
					player.getDialogueManager()
							.startDialogue("RunespanPortalD");
				else if (id == 2491)
					player.getActionManager()
							.setAction(
									new EssenceMining(
											object,
											player.getSkills().getLevel(
													Skills.MINING) < 30 ? EssenceDefinitions.Rune_Essence
													: EssenceDefinitions.Pure_Essence));
				else if (id == 16945 && object.getX() == 2137
						&& object.getY() == 3897)
					player.setNextWorldTile(new WorldTile(2137, 3895, 3));
				else if (id == 16947 && object.getX() == 2137
						&& object.getY() == 3896)
					player.setNextWorldTile(new WorldTile(2137, 3898, 2));
				else if (id == 16945 && object.getX() == 2143
						&& object.getY() == 3897)
					player.setNextWorldTile(new WorldTile(2143, 3895, 3));
				else if (id == 16947 && object.getX() == 2143
						&& object.getY() == 3896)
					player.setNextWorldTile(new WorldTile(2143, 3898, 2));
				else if (id == 16945 && object.getX() == 2143
						&& object.getY() == 3909)
					player.setNextWorldTile(new WorldTile(2143, 3911, 3));
				else if (id == 16497 && object.getX() == 2143
						&& object.getY() == 3909)
					player.setNextWorldTile(new WorldTile(2143, 3908, 2));
				else if (id == 16495 && object.getX() == 2137
						&& object.getY() == 3909)
					player.setNextWorldTile(new WorldTile(2137, 3911, 3));
				else if (id == 16947 && object.getX() == 2137
						&& object.getY() == 3909)
					player.setNextWorldTile(new WorldTile(2137, 3908, 2));
				else if (id == 16947 && object.getX() == 2142
						&& object.getY() == 3895)
					player.setNextWorldTile(new WorldTile(2141, 3895, 1));
				else if (id == 16945 && object.getX() == 2142
						&& object.getY() == 3895)
					player.setNextWorldTile(new WorldTile(2144, 3895, 2));
				else if (id == 16945 && object.getX() == 2138
						&& object.getY() == 3895)
					player.setNextWorldTile(new WorldTile(2136, 3895, 2));
				else if (id == 16947 && object.getX() == 2137
						&& object.getY() == 3895)
					player.setNextWorldTile(new WorldTile(2139, 3895, 1));
				else if (id == 2478)
					Runecrafting.craftEssence(player, 556, 1, 5, false, 11, 2,
							22, 3, 34, 4, 44, 5, 55, 6, 66, 7, 77, 88, 9, 99,
							10);
				else if (id == 2479)
					Runecrafting.craftEssence(player, 558, 2, 5.5, false, 14,
							2, 28, 3, 42, 4, 56, 5, 70, 6, 84, 7, 98, 8);
				else if (id == 2480)
					Runecrafting.craftEssence(player, 555, 5, 6, false, 19, 2,
							38, 3, 57, 4, 76, 5, 95, 6);
				else if (id == 2481)
					Runecrafting.craftEssence(player, 557, 9, 6.5, false, 26,
							2, 52, 3, 78, 4);
				else if (id == 2482)
					Runecrafting.craftEssence(player, 554, 14, 7, false, 35, 2,
							70, 3);
				else if (id == 2483)
					Runecrafting.craftEssence(player, 559, 20, 7.5, false, 46,
							2, 92, 3);
				else if (id == 2484)
					Runecrafting.craftEssence(player, 564, 27, 8, true, 59, 2);
				else if (id == 2487)
					Runecrafting
							.craftEssence(player, 562, 35, 8.5, true, 74, 2);
				else if (id == 17010)
					Runecrafting.craftEssence(player, 9075, 40, 8.7, true, 82,
							2);
				else if (id == 2486)
					Runecrafting.craftEssence(player, 561, 45, 9, true, 91, 2);
				else if (id == 2485)
					Runecrafting.craftEssence(player, 563, 50, 9.5, true);
				else if (id == 2488)
					Runecrafting.craftEssence(player, 560, 65, 10, true);
				else if (id == 30624)
					Runecrafting.craftEssence(player, 565, 77, 10.5, true);
				else if (id == 2452) {
					int hatId = player.getEquipment().getHatId();
					if (hatId == Runecrafting.AIR_TIARA
							|| hatId == Runecrafting.OMNI_TIARA
							|| player.getInventory().containsItem(1438, 1))
						Runecrafting.enterAirAltar(player);
				} else if (id == 2455) {
					int hatId = player.getEquipment().getHatId();
					if (hatId == Runecrafting.EARTH_TIARA
							|| hatId == Runecrafting.OMNI_TIARA
							|| player.getInventory().containsItem(1440, 1))
						Runecrafting.enterEarthAltar(player);
				} else if (id == 2456) {
					int hatId = player.getEquipment().getHatId();
					if (hatId == Runecrafting.FIRE_TIARA
							|| hatId == Runecrafting.OMNI_TIARA
							|| player.getInventory().containsItem(1442, 1))
						Runecrafting.enterFireAltar(player);
				} else if (id == 2454) {
					int hatId = player.getEquipment().getHatId();
					if (hatId == Runecrafting.WATER_TIARA
							|| hatId == Runecrafting.OMNI_TIARA
							|| player.getInventory().containsItem(1444, 1))
						Runecrafting.enterWaterAltar(player);
				} else if (id == 2457) {
					int hatId = player.getEquipment().getHatId();
					if (hatId == Runecrafting.BODY_TIARA
							|| hatId == Runecrafting.OMNI_TIARA
							|| player.getInventory().containsItem(1446, 1))
						Runecrafting.enterBodyAltar(player);
				} else if (id == 2453) {
					int hatId = player.getEquipment().getHatId();
					if (hatId == Runecrafting.MIND_TIARA
							|| hatId == Runecrafting.OMNI_TIARA
							|| player.getInventory().containsItem(1448, 1))
						Runecrafting.enterMindAltar(player);
				} else if (id == 47120) { // zaros altar
					// recharge if needed
					if (player.getPrayer().getPrayerpoints() < player
							.getSkills().getLevelForXp(Skills.PRAYER) * 10) {
						player.lock(12);
						player.setNextAnimation(new Animation(12563));
						player.getPrayer().setPrayerpoints(
								(int) ((player.getSkills().getLevelForXp(
										Skills.PRAYER) * 10) * 1.15));
						player.getPrayer().refreshPrayerPoints();
					}
					player.getDialogueManager().startDialogue("ZarosAltar");
				} else if (id == 19222)
					Falconry.beginFalconry(player);
				else if (id == 36786)
					player.getDialogueManager().startDialogue("Banker", 4907);
				else if (id == 42377 || id == 42378)
					player.getDialogueManager().startDialogue("Banker", 2759);
				else if (id == 42217 || id == 782 || id == 34752)
					player.getDialogueManager().startDialogue("Banker", 553);
				else if (id == 57437)
					player.getBank().openBank();
				else if (id == 66449)
					player.getBank().openBank();
				else if (id == 69514)
					AdvancedGnomeAgility.RunGnomeBoard(player, object);
				else if (id == 69389)
					AdvancedGnomeAgility.JumpDown(player, object);
				else if (id == 69506)
					AdvancedGnomeAgility.climbUpGnomeTreeBranch(player);
				else if (id == 65365)
					WildernessAgility.GateWalk(player, object);
				else if (id == 65734)
					WildernessAgility.climbCliff(player, object);
				else if (id == 65362)
					WildernessAgility.enterObstaclePipe(player, object.getX(),
							object.getY());
				else if (id == 64696)
					WildernessAgility.swingOnRopeSwing(player, object);
				else if (id == 64698)
					WildernessAgility.walkLog(player);
				else if (id == 64699)
					WildernessAgility.crossSteppingPalletes(player, object);
				else if (id == 42425 && object.getX() == 3220
						&& object.getY() == 3222) { // zaros portal
					player.useStairs(10256, new WorldTile(3353, 3416, 0), 4, 5,
							"And you find yourself into a digsite.");
					player.addWalkSteps(3222, 3223, -1, false);
					player.getPackets().sendGameMessage(
							"You examine portal and it aborves you...");
				} else if (id == 9356)
					FightCaves.enterFightCaves(player);
				else if (id == 68107)
					FightKiln.enterFightKiln(player, false);
				else if (id == 68223)
					FightPits.enterLobby(player, false);
				else if (id == 46500 && object.getX() == 3351
						&& object.getY() == 3415) { // zaros portal
					player.useStairs(-1, new WorldTile(
							Settings.RESPAWN_PLAYER_LOCATION.getX(),
							Settings.RESPAWN_PLAYER_LOCATION.getY(),
							Settings.RESPAWN_PLAYER_LOCATION.getPlane()), 2, 3,
							"You found your way back to home.");
					player.addWalkSteps(3351, 3415, -1, false);
				} else if (id == 9293) {
					if (player.getSkills().getLevel(Skills.AGILITY) < 70) {
						player.getPackets()
								.sendGameMessage(
										"You need an agility level of 70 to use this obstacle.",
										true);
						return;
					}
					int x = player.getX() == 2886 ? 2892 : 2886;
					WorldTasksManager.schedule(new WorldTask() {
						int count = 0;

						@Override
						public void run() {
							player.setNextAnimation(new Animation(844));
							if (count++ == 1)
								stop();
						}

					}, 0, 0);
					player.setNextForceMovement(new ForceMovement(
							new WorldTile(x, 9799, 0), 3,
							player.getX() == 2886 ? 1 : 3));
					player.useStairs(-1, new WorldTile(x, 9799, 0), 3, 4);
				} else if (id == 29370
						&& (object.getX() == 3150 || object.getX() == 3153)
						&& object.getY() == 9906) { // edgeville dungeon cut
					if (player.getSkills().getLevel(Skills.AGILITY) < 53) {
						player.getPackets()
								.sendGameMessage(
										"You need an agility level of 53 to use this obstacle.");
						return;
					}
					final boolean running = player.getRun();
					player.setRunHidden(false);
					player.lock(8);
					player.addWalkSteps(x == 3150 ? 3155 : 3149, 9906, -1,
							false);
					player.getPackets().sendGameMessage(
							"You pulled yourself through the pipes.", true);
					WorldTasksManager.schedule(new WorldTask() {
						boolean secondloop;

						@Override
						public void run() {
							if (!secondloop) {
								secondloop = true;
								player.getAppearence().setRenderEmote(295);
							} else {
								player.getAppearence().setRenderEmote(-1);
								player.setRunHidden(running);
								player.getSkills().addXp(Skills.AGILITY, 7);
								stop();
							}
						}
					}, 0, 5);
				}
				// start forinthry dungeon
				else if (id == 18341 && object.getX() == 3036
						&& object.getY() == 10172)
					player.useStairs(-1, new WorldTile(3039, 3765, 0), 0, 1);
				else if (id == 20599 && object.getX() == 3038
						&& object.getY() == 3761)
					player.useStairs(-1, new WorldTile(3037, 10171, 0), 0, 1);
				else if (id == 18342 && object.getX() == 3075
						&& object.getY() == 10057)
					player.useStairs(-1, new WorldTile(3071, 3649, 0), 0, 1);
				else if (id == 20600 && object.getX() == 3072
						&& object.getY() == 3648)
					player.useStairs(-1, new WorldTile(3077, 10058, 0), 0, 1);
				// nomads requiem
				else if (id == 18425
						&& !player.getQuestManager().completedQuest(
								Quests.NOMADS_REQUIEM))
					NomadsRequiem.enterNomadsRequiem(player);
				else if (id == 42219) {
					player.getControlerManager().startControler("Soulwars");
					if (player.getQuestManager().getQuestStage(
							Quests.NOMADS_REQUIEM) == -2) // for now, on future
															// talk with npc +
															// quest reqs
						player.getQuestManager().setQuestStageAndRefresh(
								Quests.NOMADS_REQUIEM, 0);
				} else if (id == 8689)
					player.getActionManager().setAction(new CowMilkingAction());
				else if (id == 59463) // citadel
					player.getDialogueManager().startDialogue("Enter");
				else if (id == 42220)
					player.useStairs(-1, new WorldTile(3082, 3475, 0), 0, 1);
				// start falador mininig
				else if (id == 30942 && object.getX() == 3019
						&& object.getY() == 3450)
					player.useStairs(828, new WorldTile(3020, 9850, 0), 1, 2);
				else if (id == 6226 && object.getX() == 3019
						&& object.getY() == 9850)
					player.useStairs(833, new WorldTile(3018, 3450, 0), 1, 2);
				else if (id == 31002
						&& player.getQuestManager().completedQuest(
								Quests.PERIL_OF_ICE_MONTAINS))
					player.useStairs(833, new WorldTile(2998, 3452, 0), 1, 2);
				else if (id == 31012
						&& player.getQuestManager().completedQuest(
								Quests.PERIL_OF_ICE_MONTAINS))
					player.useStairs(828, new WorldTile(2996, 9845, 0), 1, 2);
				else if (id == 30943 && object.getX() == 3059
						&& object.getY() == 9776)
					player.useStairs(-1, new WorldTile(3061, 3376, 0), 0, 1);
				else if (id == 30944 && object.getX() == 3059
						&& object.getY() == 3376)
					player.useStairs(-1, new WorldTile(3058, 9776, 0), 0, 1);
				else if (id == 2112 && object.getX() == 3046
						&& object.getY() == 9756) {
					if (player.getSkills().getLevelForXp(Skills.MINING) < 60) {
						player.getDialogueManager()
								.startDialogue(
										"SimpleNPCMessage",
										MiningGuildDwarf
												.getClosestDwarfID(player),
										"Sorry, but you need level 60 Mining to go in there.");
						return;
					}
					WorldObject openedDoor = new WorldObject(object.getId(),
							object.getType(), object.getRotation() - 1, object
									.getX(), object.getY() + 1, object
									.getPlane());
					if (World.removeTemporaryObject(object, 1200, false)) {
						World.spawnTemporaryObject(openedDoor, 1200, false);
						player.lock(2);
						player.stopAll();
						player.addWalkSteps(3046,
								player.getY() > object.getY() ? object.getY()
										: object.getY() + 1, -1, false);
					}
				} else if (id == 47236) {
					BossCaveHandler.handlePortals(player, object);
				} else if (id == 31314) {
					AncientTempleHandler.handleWaveringMysticBarrier(player, object);
				} else if (id == 47237) {
					AncientTempleHandler.handleGap(player, object);
				} else if (id == 31435) {
					AncientTempleHandler.handleBarriers(player, object);
				} else if (id == 31412) {
					AncientTempleHandler.enterRift(player, object);
				} else if (id == 13999) {
					ElementRiftHandler.handleRope(player, object);
				} else if (id == 47231) {
					player.move(new WorldTile (Settings.RESPAWN_PLAYER_LOCATION));
				} else if (id == 2113) {
					if (player.getSkills().getLevelForXp(Skills.MINING) < 60) {
						player.getDialogueManager()
								.startDialogue(
										"SimpleNPCMessage",
										MiningGuildDwarf
												.getClosestDwarfID(player),
										"Sorry, but you need level 60 Mining to go in there.");
						return;
					}
					player.useStairs(-1, new WorldTile(3021, 9739, 0), 0, 1);
				} else if (id == 6226 && object.getX() == 3019
						&& object.getY() == 9740)
					player.useStairs(828, new WorldTile(3019, 3341, 0), 1, 2);
				else if (id == 6226 && object.getX() == 3019
						&& object.getY() == 9738)
					player.useStairs(828, new WorldTile(3019, 3337, 0), 1, 2);
				else if (id == 6226 && object.getX() == 3018
						&& object.getY() == 9739)
					player.useStairs(828, new WorldTile(3017, 3339, 0), 1, 2);
				else if (id == 6226 && object.getX() == 3020
						&& object.getY() == 9739)
					player.useStairs(828, new WorldTile(3021, 3339, 0), 1, 2);
				else if (id == 30963)
					player.getBank().openBank();
				else if (id == 6045)
					player.getPackets().sendGameMessage(
							"You search the cart but find nothing.");
				else if (id == 5906) {
					if (player.getSkills().getLevel(Skills.AGILITY) < 42) {
						player.getPackets()
								.sendGameMessage(
										"You need an agility level of 42 to use this obstacle.");
						return;
					}
					player.lock();
					WorldTasksManager.schedule(new WorldTask() {
						int count = 0;

						@Override
						public void run() {
							if (count == 0) {
								player.setNextAnimation(new Animation(2594));
								WorldTile tile = new WorldTile(
										object.getX()
												+ (object.getRotation() == 2 ? -2
														: +2), object.getY(), 0);
								player.setNextForceMovement(new ForceMovement(
										tile, 4, Utils.getMoveDirection(
												tile.getX() - player.getX(),
												tile.getY() - player.getY())));
							} else if (count == 2) {
								WorldTile tile = new WorldTile(
										object.getX()
												+ (object.getRotation() == 2 ? -2
														: +2), object.getY(), 0);
								player.setNextWorldTile(tile);
							} else if (count == 5) {
								player.setNextAnimation(new Animation(2590));
								WorldTile tile = new WorldTile(
										object.getX()
												+ (object.getRotation() == 2 ? -5
														: +5), object.getY(), 0);
								player.setNextForceMovement(new ForceMovement(
										tile, 4, Utils.getMoveDirection(
												tile.getX() - player.getX(),
												tile.getY() - player.getY())));
							} else if (count == 7) {
								WorldTile tile = new WorldTile(
										object.getX()
												+ (object.getRotation() == 2 ? -5
														: +5), object.getY(), 0);
								player.setNextWorldTile(tile);
							} else if (count == 10) {
								player.setNextAnimation(new Animation(2595));
								WorldTile tile = new WorldTile(
										object.getX()
												+ (object.getRotation() == 2 ? -6
														: +6), object.getY(), 0);
								player.setNextForceMovement(new ForceMovement(
										tile, 4, Utils.getMoveDirection(
												tile.getX() - player.getX(),
												tile.getY() - player.getY())));
							} else if (count == 12) {
								WorldTile tile = new WorldTile(
										object.getX()
												+ (object.getRotation() == 2 ? -6
														: +6), object.getY(), 0);
								player.setNextWorldTile(tile);
							} else if (count == 14) {
								stop();
								player.unlock();
							}
							count++;
						}

					}, 0, 0);
					// BarbarianOutpostAgility start
				} else if (id == 20210)
					BarbarianOutpostAgility.enterObstaclePipe(player, object);
				else if (id == 43526)
					BarbarianOutpostAgility.swingOnRopeSwing(player, object);
				else if (id == 43595 && x == 2550 && y == 3546)
					BarbarianOutpostAgility
							.walkAcrossLogBalance(player, object);
				else if (id == 20211 && x == 2538 && y == 3545)
					BarbarianOutpostAgility.climbObstacleNet(player, object);
				else if (id == 2302 && x == 2535 && y == 3547)
					BarbarianOutpostAgility.walkAcrossBalancingLedge(player,
							object);
				else if (id == 1948)
					BarbarianOutpostAgility.climbOverCrumblingWall(player,
							object);
				else if (id == 43533)
					BarbarianOutpostAgility.runUpWall(player, object);
				else if (id == 43597)
					BarbarianOutpostAgility.climbUpWall(player, object);
				else if (id == 43587)
					BarbarianOutpostAgility.fireSpringDevice(player, object);
				else if (id == 43527)
					BarbarianOutpostAgility.crossBalanceBeam(player, object);
				else if (id == 43531)
					BarbarianOutpostAgility.jumpOverGap(player, object);
				else if (id == 43532)
					BarbarianOutpostAgility.slideDownRoof(player, object);
				/**
				 * 
				 * Lava flow mine handling.
				 * 
				 */
				else if (id == 57171)
					player.getActionManager().setAction(
							new LavaFlowMine(object));
				else if (id == 57180)
					player.getActionManager().setAction(
							new LavaFlowMine(object));
				else if (id == 57169)
					player.getActionManager().setAction(
							new LavaFlowMine(object));
				else if (id == 57179)
					player.getActionManager().setAction(
							new LavaFlowMine(object));
				else if (id == 57172)
					player.getActionManager().setAction(
							new LavaFlowMine(object));
				else if (id == 57170)
					player.getActionManager().setAction(
							new LavaFlowMine(object));
				else if (id == 57176)
					player.getActionManager().setAction(
							new LavaFlowMine(object));
				else if (id == 57177)
					player.getActionManager().setAction(
							new LavaFlowMine(object));
				// rock living caverns
				else if (id == 45077) {
					player.lock();
					if (player.getX() != object.getX()
							|| player.getY() != object.getY())
						player.addWalkSteps(object.getX(), object.getY(), -1,
								false);
					WorldTasksManager.schedule(new WorldTask() {

						private int count;

						@Override
						public void run() {
							if (count == 0) {
								player.setNextFaceWorldTile(new WorldTile(
										object.getX() - 1, object.getY(), 0));
								player.setNextAnimation(new Animation(12216));
								player.unlock();
							} else if (count == 2) {
								player.setNextWorldTile(new WorldTile(3651,
										5122, 0));
								player.setNextFaceWorldTile(new WorldTile(3651,
										5121, 0));
								player.setNextAnimation(new Animation(12217));
							} else if (count == 3) {
								// TODO find emote
								// player.getPackets().sendObjectAnimation(new
								// WorldObject(45078, 0, 3, 3651, 5123, 0), new
								// Animation(12220));
							} else if (count == 5) {
								player.unlock();
								stop();
							}
							count++;
						}

					}, 1, 0);
				} else if (id == 45076)
					player.getActionManager().setAction(
							new Mining(object, RockDefinitions.LRC_Gold_Ore));
				else if (id == 5999)
					player.getActionManager().setAction(
							new Mining(object, RockDefinitions.LRC_Coal_Ore));
				else if (id == 45078)
					player.useStairs(2413, new WorldTile(3012, 9832, 0), 2, 2);
				else if (id == 24720)
					player.getDialogueManager().startDialogue("SmeltingD",
							object);
				else if (id == 45079)
					player.getBank().openDepositBox();
				else if (id == 2330)
					player.getActionManager().setAction(
							new Mining(object,
									RockDefinitions.Red_Standstone_Ore));
				// champion guild
				else if (id == 24357 && object.getX() == 3188
						&& object.getY() == 3355)
					player.useStairs(-1, new WorldTile(3189, 3354, 1), 0, 1);
				else if (id == 24359 && object.getX() == 3188
						&& object.getY() == 3355)
					player.useStairs(-1, new WorldTile(3189, 3358, 0), 0, 1);
				else if (id == 1805 && object.getX() == 3191
						&& object.getY() == 3363) {
					WorldObject openedDoor = new WorldObject(object.getId(),
							object.getType(), object.getRotation() - 1, object
									.getX(), object.getY(), object.getPlane());
					if (World.removeTemporaryObject(object, 1200, false)) {
						World.spawnTemporaryObject(openedDoor, 1200, false);
						player.lock(2);
						player.stopAll();
						player.addWalkSteps(3191, player.getY() >= object
								.getY() ? object.getY() - 1 : object.getY(),
								-1, false);
						if (player.getY() >= object.getY())
							player.getDialogueManager()
									.startDialogue(
											"SimpleNPCMessage",
											198,
											"Greetings bolt adventurer. Welcome to the guild of",
											"Champions.");
					}
				}
				// start of varrock dungeon
				else if (id == 29355 && object.getX() == 3230
						&& object.getY() == 9904) // varrock dungeon climb to
													// bear
					player.useStairs(828, new WorldTile(3229, 3503, 0), 1, 2);
				/**
				 * 
				 * Lumbridge objects.
				 * 
				 */
				else if (id == 36687) {
					player.getPackets().sendGameMessage(
							"You look down and see nothing but darkness...");
					player.getDialogueManager().startDialogue(
							"SimplePlayerMessage",
							"It wouldn't be smart to climb down there...");
				} else if (id == 37683) {
					player.getPackets().sendGameMessage(
							"You look down and see nothing but darkness...");
					player.getDialogueManager().startDialogue(
							"SimplePlayerMessage",
							"It wouldn't be smart to climb down there...");
				} else if (id == 45483)
					player.setNextWorldTile(new WorldTile(3232, 3241, 1));
				else if (id == 45484)
					player.setNextWorldTile(new WorldTile(3232, 3238, 0));
				else if (id == 24264)
					player.useStairs(833, new WorldTile(3229, 9904, 0), 1, 2);
				else if (id == 24366)
					player.useStairs(828, new WorldTile(3237, 3459, 0), 1, 2);
				else if (id == 882 && object.getX() == 3237
						&& object.getY() == 3458)
					player.useStairs(833, new WorldTile(3237, 9858, 0), 1, 2);
				else if (id == 29355 && object.getX() == 3097
						&& object.getY() == 9867) // edge dungeon climb
					player.useStairs(828, new WorldTile(3096, 3468, 0), 1, 2);
				else if (id == 26934)
					player.useStairs(833, new WorldTile(3097, 9868, 0), 1, 2);
				else if (id == 29355 && object.getX() == 3088
						&& object.getY() == 9971)
					player.useStairs(828, new WorldTile(3087, 3571, 0), 1, 2);
				else if (id == 65453)
					player.useStairs(833, new WorldTile(3089, 9971, 0), 1, 2);
				else if (id == 12389 && object.getX() == 3116
						&& object.getY() == 3452)
					player.useStairs(833, new WorldTile(3117, 9852, 0), 1, 2);
				else if (id == 29355 && object.getX() == 3116
						&& object.getY() == 9852)
					player.useStairs(833, new WorldTile(3115, 3452, 0), 1, 2);
				else if (id == 69526)
					GnomeAgility.walkGnomeLog(player);
				else if (id == 69383)
					GnomeAgility.climbGnomeObstacleNet(player);
				else if (id == 69508)
					GnomeAgility.climbUpGnomeTreeBranch(player);
				else if (id == 2312)
					GnomeAgility.walkGnomeRope(player);
				else if (id == 4059)
					GnomeAgility.walkBackGnomeRope(player);
				else if (id == 69507)
					GnomeAgility.climbDownGnomeTreeBranch(player);
				else if (id == 69384)
					GnomeAgility.climbGnomeObstacleNet2(player);
				else if (id == 69377 || id == 69378)
					GnomeAgility.enterGnomePipe(player, object.getX(),
							object.getY());
				else if (Wilderness.isDitch(id)) {// wild ditch
					player.getDialogueManager().startDialogue(
							"WildernessDitch", object);
				} else if (id == 42611) {// Magic Portal
					player.getDialogueManager().startDialogue("MagicPortal");
				} else if (object.getDefinitions().name
						.equalsIgnoreCase("Obelisk") && object.getY() > 3525) {
					// Who the fuck removed the controler class and the code
					// from SONIC!!!!!!!!!!
					// That was an hour of collecting coords :fp: Now ima kill
					// myself.
				} else if (id == 27254) {// Edgeville portal
					player.getPackets().sendGameMessage(
							"You enter the portal...");
					player.useStairs(10584, new WorldTile(3087, 3488, 0), 2, 3,
							"..and are transported to Edgeville.");
					player.addWalkSteps(1598, 4506, -1, false);
				} else if (id == 12202) {// mole entrance

					if (!player.getInventory().containsItem(952, 1)) {
						player.getPackets().sendGameMessage(
								"You need a spade to dig this.");
						return;
					}
					if (player.getX() != object.getX()
							|| player.getY() != object.getY()) {
						player.lock();
						player.addWalkSteps(object.getX(), object.getY());
						WorldTasksManager.schedule(new WorldTask() {
							@Override
							public void run() {
								InventoryOptionsHandler.dig(player);
							}

						}, 1);
					} else
						InventoryOptionsHandler.dig(player);
				} else if (id == 12230 && object.getX() == 1752
						&& object.getY() == 5136) {// mole exit
					player.setNextWorldTile(new WorldTile(2986, 3316, 0));
				} else if (id == 35549) {
					player.setNextWorldTile(new WorldTile(3268, 3227, 0));
				} else if (id == 35551) {
					player.setNextWorldTile(new WorldTile(3267, 3227, 0));
				} else if (id == 15522) {// portal sign
					if (player.withinDistance(new WorldTile(1598, 4504, 0), 1)) {// PORTAL
						// 1
						player.getInterfaceManager().sendInterface(327);
						player.getPackets().sendIComponentText(327, 13,
								"Edgeville");
						player.getPackets()
								.sendIComponentText(
										327,
										14,
										"This portal will take you to edgeville. There "
												+ "you can multi pk once past the wilderness ditch.");
					}
					if (player.withinDistance(new WorldTile(1598, 4508, 0), 1)) {// PORTAL
						// 2
						player.getInterfaceManager().sendInterface(327);
						player.getPackets().sendIComponentText(327, 13,
								"Mage Bank");
						player.getPackets()
								.sendIComponentText(
										327,
										14,
										"This portal will take you to the mage bank. "
												+ "The mage bank is a 1v1 deep wilderness area.");
					}
					if (player.withinDistance(new WorldTile(1598, 4513, 0), 1)) {// PORTAL
						// 3
						player.getInterfaceManager().sendInterface(327);
						player.getPackets().sendIComponentText(327, 13,
								"Magic's Portal");
						player.getPackets()
								.sendIComponentText(
										327,
										14,
										"This portal will allow you to teleport to areas that "
												+ "will allow you to change your magic spell book.");
					}
				} else if (id == 38811 || id == 37929) {// corp beast
					if (object.getX() == 2971 && object.getY() == 4382)
						player.getInterfaceManager().sendInterface(650);
					else if (object.getX() == 2918 && object.getY() == 4382) {
						player.stopAll();
						player.setNextWorldTile(new WorldTile(
								player.getX() == 2921 ? 2917 : 2921, player
										.getY(), player.getPlane()));
					}
				} else if (id == 37928 && object.getX() == 2883
						&& object.getY() == 4370) {
					player.stopAll();
					player.setNextWorldTile(new WorldTile(3214, 3782, 0));
					player.getControlerManager().startControler("Wilderness");
				} else if (id == 38815 && object.getX() == 3209
						&& object.getY() == 3780 && object.getPlane() == 0) {
					if (player.getSkills().getLevelForXp(Skills.WOODCUTTING) < 37
							|| player.getSkills().getLevelForXp(Skills.MINING) < 45
							|| player.getSkills().getLevelForXp(
									Skills.SUMMONING) < 23
							|| player.getSkills().getLevelForXp(
									Skills.FIREMAKING) < 47
							|| player.getSkills().getLevelForXp(Skills.PRAYER) < 55) {
						player.getPackets()
								.sendGameMessage(
										"You need 23 Summoning, 37 Woodcutting, 45 Mining, 47 Firemaking and 55 Prayer to enter this dungeon.");
						return;
					}
					player.stopAll();
					player.setNextWorldTile(new WorldTile(2885, 4372, 2));
					player.getControlerManager().forceStop();
					// TODO all reqs, skills not added
				} else if (id == 48803 && player.isKalphiteLairSetted()) {
					player.setNextWorldTile(new WorldTile(3508, 9494, 0));
				} else if (id == 48802 && player.isKalphiteLairEntranceSetted()) {
					player.setNextWorldTile(new WorldTile(3483, 9510, 2));
				} else if (id == 3829) {
					if (object.getX() == 3483 && object.getY() == 9510) {
						player.useStairs(828, new WorldTile(3226, 3108, 0), 1,
								2);
					}
				} else if (id == 3832) {
					if (object.getX() == 3508 && object.getY() == 9494) {
						player.useStairs(828, new WorldTile(3509, 9496, 2), 1,
								2);
					}
				} else if (id == 9369) {
					player.getControlerManager().startControler("FightPits");
				} else if (id == 66795) { // Warriors Guild
					player.setNextWorldTile(new WorldTile(2841, 3534, 1));
				} else if (id == 66796) { // Warriors Guild
					player.setNextWorldTile(new WorldTile(2841, 3534, 2));
				} else if (id == 66797) { // Warriors Guild
					player.setNextWorldTile(new WorldTile(2841, 3534, 1));
				} else if (id == 24358) { // Museum
					player.setNextWorldTile(new WorldTile(3266, 3455, 1));
				} else if (id == 24359) { // Museum
					player.setNextWorldTile(new WorldTile(3266, 3451, 0));
				} else if (id == 24357) { // Museum
					player.setNextWorldTile(new WorldTile(3254, 3446, 2));
				} else if (id == 24359) { // Museum
					player.setNextWorldTile(new WorldTile(3254, 3442, 1));
				} else if (id == 4493) { // Slayer Tower
					player.setNextWorldTile(new WorldTile(3433, 3538, 1));
				} else if (id == 4494) { // Slayer Tower
					player.setNextWorldTile(new WorldTile(3438, 3538, 0));
				} else if (id == 4496) { // Slayer Tower
					player.setNextWorldTile(new WorldTile(3412, 3541, 1));
				} else if (id == 4495) { // Slayer Tower
					player.setNextWorldTile(new WorldTile(3417, 3541, 2));
				} else if (id == 9319) { // Slayer Tower
					player.setNextAnimation(new Animation(828));
					if (object.getX() == 3447 && object.getY() == 3576
							&& object.getPlane() == 1) {
						player.setNextWorldTile(new WorldTile(3446, 3576, 2));
					}
					if (object.getX() == 3422 && object.getY() == 3550
							&& object.getPlane() == 0) {
						player.setNextWorldTile(new WorldTile(3422, 3551, 1));
					}
					player.stopAll();
				} else if (id == 9320) { // Slayer Tower
					player.setNextAnimation(new Animation(828));
					if (object.getX() == 3447 && object.getY() == 3576
							&& object.getPlane() == 2) {
						player.setNextWorldTile(new WorldTile(3446, 3576, 1));
					}
					if (object.getX() == 3422 && object.getY() == 3550
							&& object.getPlane() == 1) {
						player.setNextWorldTile(new WorldTile(3422, 3551, 0));
					}
					player.stopAll();
				} else if (id == 54019 || id == 54020 || id == 55301)
					PkRank.showRanks(player);
				else if (id == 1817 && object.getX() == 2273
						&& object.getY() == 4680) { // kbd lever
					Magic.pushLeverTeleport(player, new WorldTile(3067, 10254,
							0));
				} else if (id == 1816 && object.getX() == 3067
						&& object.getY() == 10252) { // kbd out lever
					Magic.pushLeverTeleport(player,
							new WorldTile(2273, 4681, 0));
				} else if (id == 32015 && object.getX() == 3069
						&& object.getY() == 10256) { // kbd stairs
					player.useStairs(828, new WorldTile(3017, 3848, 0), 1, 2);
					player.getControlerManager().startControler("Wilderness");
					// Start of Runecrafting Portal Exit
				} else if (id == 2465) { // portal
					player.setNextWorldTile(new WorldTile(2858, 3336, 0));
				} else if (id == 2469) { // portal
					player.setNextWorldTile(new WorldTile(2858, 3336, 0));
				} else if (id == 2473) { // portal
					player.setNextWorldTile(new WorldTile(2858, 3336, 0));
				} else if (id == 2475) { // portal
					player.setNextWorldTile(new WorldTile(2858, 3336, 0));
				} else if (id == 2466) { // portal
					player.setNextWorldTile(new WorldTile(2858, 3336, 0));
				} else if (id == 2471) { // portal
					player.setNextWorldTile(new WorldTile(2858, 3336, 0));
				} else if (id == 2474) { // portal
					player.setNextWorldTile(new WorldTile(2858, 3336, 0));
				} else if (id == 2467) { // portal
					player.setNextWorldTile(new WorldTile(2858, 3336, 0));
				} else if (id == 2468) { // portal
					player.setNextWorldTile(new WorldTile(2858, 3336, 0));
				} else if (id == 2470) { // portal
					player.setNextWorldTile(new WorldTile(2858, 3336, 0));
				} else if (id == 2472) { // portal
					player.setNextWorldTile(new WorldTile(2858, 3336, 0));
				} else if (id == 2477) { // portal
					player.setNextWorldTile(new WorldTile(2858, 3336, 0));
					// End of Runecrafting Portal Exit
					// Start of Runecrafting Abyss Entrances
				} else if (id == 7133) { // nature rift
					player.setNextWorldTile(new WorldTile(2398, 4841, 0));
				} else if (id == 7132) { // cosmic rift
					player.setNextWorldTile(new WorldTile(2162, 4833, 0));
				} else if (id == 7141) { // blood rift
					player.setNextWorldTile(new WorldTile(2462, 4891, 1));
				} else if (id == 7129) { // fire rift
					player.setNextWorldTile(new WorldTile(2584, 4836, 0));
				} else if (id == 7130) { // earth rift
					player.setNextWorldTile(new WorldTile(2660, 4839, 0));
				} else if (id == 7131) { // body rift
					player.setNextWorldTile(new WorldTile(2527, 4833, 0));
				} else if (id == 7140) { // mind rift
					player.setNextWorldTile(new WorldTile(2794, 4830, 0));
				} else if (id == 7139) { // air rift
					player.setNextWorldTile(new WorldTile(2845, 4832, 0));
				} else if (id == 7137) { // water rift
					player.setNextWorldTile(new WorldTile(3482, 4836, 0));
				} else if (id == 7136) { // death rift
					player.setNextWorldTile(new WorldTile(2207, 4836, 0));
				} else if (id == 7135) { // law rift
					player.setNextWorldTile(new WorldTile(2464, 4834, 0));
				} else if (id == 7134) { // chaotic rift
					player.setNextWorldTile(new WorldTile(2269, 4843, 0));
					// End of Runecrafting Abyss Exits
				} else if (id == 7138) { // soul rift
					player.getPackets().sendGameMessage(
							"A strange power blocks your entrance.");
				} else if (id == 1765 && object.getX() == 3017
						&& object.getY() == 3849) { // kbd out stairs
					player.stopAll();
					player.setNextWorldTile(new WorldTile(3069, 10255, 0));
					player.getControlerManager().forceStop();
				} else if (id == 48496) {
					player.getDialogueManager().startDialogue("EnteringDung");
				} else if (id == 67747) {
					player.getControlerManager().startControler(
							"TrollInvasion", 1);
				} else if ((id == 14315) || (id == 14314)) {
					player.setPestControl(new PestControl(player));
					player.getPestControl().handleObjectClick1(player, object);
				} else if (id == 5959) {
					Magic.pushLeverTeleport(player,
							new WorldTile(2539, 4712, 0));
				} else if (id == 5960) {
					Magic.pushLeverTeleport(player,
							new WorldTile(3089, 3957, 0));
				} else if (id == 1814) {
					Magic.pushLeverTeleport(player,
							new WorldTile(3155, 3923, 0));
				} else if (id == 1815) {
					Magic.pushLeverTeleport(player,
							new WorldTile(2561, 3311, 0));
				} else if (id == 62675)
					player.getCutscenesManager().play("DTPreview");
				else if (id == 62681)
					player.getDominionTower().viewScoreBoard();
				else if (id == 62678 || id == 62679)
					player.getDominionTower().openModes();
				else if (id == 62688) // DT Rewards
					player.getDialogueManager().startDialogue("DTRewards");
				else if (id == 2145)
					player.getDialogueManager()
							.startDialogue("TeleportCrystal");
				else if (id == 62677)
					player.getDominionTower().talkToFace();
				else if (id == 62680)
					player.getDominionTower().openBankChest();
				else if (id == 48797)
					player.useStairs(-1, new WorldTile(3877, 5526, 1), 0, 1);
				else if (id == 48798)
					player.useStairs(-1, new WorldTile(3246, 3198, 0), 0, 1);
				else if (id == 48678 && x == 3858 && y == 5533)
					player.useStairs(-1, new WorldTile(3861, 5533, 0), 0, 1);
				else if (id == 48678 && x == 3858 && y == 5543)
					player.useStairs(-1, new WorldTile(3861, 5543, 0), 0, 1);
				else if (id == 48678 && x == 3858 && y == 5533)
					player.useStairs(-1, new WorldTile(3861, 5533, 0), 0, 1);
				else if (id == 48677 && x == 3858 && y == 5543)
					player.useStairs(-1, new WorldTile(3856, 5543, 1), 0, 1);
				else if (id == 48677 && x == 3858 && y == 5533)
					player.useStairs(-1, new WorldTile(3856, 5533, 1), 0, 1);
				else if (id == 48679)
					player.useStairs(-1, new WorldTile(3875, 5527, 1), 0, 1);
				else if (id == 48688)
					player.useStairs(-1, new WorldTile(3972, 5565, 0), 0, 1);
				else if (id == 48683)
					player.useStairs(-1, new WorldTile(3868, 5524, 0), 0, 1);
				else if (id == 48682)
					player.useStairs(-1, new WorldTile(3869, 5524, 0), 0, 1);
				else if (id == 62676) { // dominion exit
					player.useStairs(-1, new WorldTile(3374, 3093, 0), 0, 1);
				} else if (id == 62674) { // dominion entrance
					player.useStairs(-1, new WorldTile(3744, 6405, 0), 0, 1);
				} else if (id == 11711 && object.getX() == 4502
						&& object.getY() == 5657) {

					if (player.getX() == 4503 && player.getY() == 5658) {
						player.addWalkStep(4503, 5656, 4503, 5658, false);
						player.addWalkStep(4503, 5656, 4503, 5658, false);
					}
					if (player.getX() == 4503 && player.getY() == 5656) {
						player.addWalkStep(4503, 5658, 4503, 5656, false);
						player.addWalkStep(4503, 5658, 4503, 5656, false);
					}
					if (player.getX() == 4504 && player.getY() == 5658) {
						player.addWalkStep(4504, 5656, 4504, 5658, false);
						player.addWalkStep(4504, 5656, 4504, 5658, false);
					}
					if (player.getX() == 4504 && player.getY() == 5656) {
						player.addWalkStep(4504, 5658, 4504, 5656, false);
						player.addWalkStep(4504, 5658, 4504, 5656, false);
					}
					if (player.getX() == 4505 && player.getY() == 5658) {
						player.addWalkStep(4505, 5656, 4505, 5658, false);
						player.addWalkStep(4505, 5656, 4505, 5658, false);
					}
					if (player.getX() == 4505 && player.getY() == 5656) {
						player.addWalkStep(4505, 5658, 4505, 5656, false);
						player.addWalkStep(4505, 5658, 4505, 5656, false);
					}

				} else if (id == 11706 && object.getX() == 4502
						&& object.getY() == 5672) {

					if (player.getX() == 4503 && player.getY() == 5673) {
						player.addWalkStep(4503, 5671, 4503, 5673, false);
						player.addWalkStep(4503, 5671, 4503, 5673, false);
					}
					if (player.getX() == 4503 && player.getY() == 5671) {
						player.addWalkStep(4503, 5673, 4503, 5671, false);
						player.addWalkStep(4503, 5673, 4503, 5671, false);
					}
					if (player.getX() == 4504 && player.getY() == 5673) {
						player.addWalkStep(4504, 5671, 4504, 5673, false);
						player.addWalkStep(4504, 5671, 4504, 5673, false);
					}
					if (player.getX() == 4504 && player.getY() == 5671) {
						player.addWalkStep(4504, 5673, 4504, 5671, false);
						player.addWalkStep(4504, 5673, 4504, 5671, false);
					}
					if (player.getX() == 4505 && player.getY() == 5673) {
						player.addWalkStep(4505, 5671, 4505, 5673, false);
						player.addWalkStep(4505, 5671, 4505, 5673, false);
					}
					if (player.getX() == 4505 && player.getY() == 5671) {
						player.addWalkStep(4505, 5673, 4505, 5671, false);
						player.addWalkStep(4505, 5673, 4505, 5671, false);
					}
				} else if (id == 3192) {
					PkRank.showRanks(player);
				} else if (id == 65349) {
					player.useStairs(-1, new WorldTile(3044, 10325, 0), 0, 1);
				} else if (id == 32048 && object.getX() == 3043
						&& object.getY() == 10328) {
					player.useStairs(-1, new WorldTile(3045, 3927, 0), 0, 1);
				} else if (id == 26194) {
					player.getDialogueManager().startDialogue("PartyRoomLever");
				} else if (id == 61190 || id == 61191 || id == 61192
						|| id == 61193) {
					if (objectDef.containsOption(0, "Chop down"))
						player.getActionManager()
								.setAction(
										new Woodcutting(object,
												TreeDefinitions.NORMAL));
				} else if (id == 20573)
					player.getControlerManager().startControler("RefugeOfFear");
				// crucible
				else if (id == 67050)
					player.useStairs(-1, new WorldTile(3359, 6110, 0), 0, 1);
				else if (id == 67053)
					player.useStairs(-1, new WorldTile(3120, 3519, 0), 0, 1);
				else if (id == 67051)
					player.getDialogueManager().startDialogue("Marv", false);
				else if (id == 67052)
					Crucible.enterCrucibleEntrance(player);
				else {
					switch (objectDef.name.toLowerCase()) {
					case "trapdoor":
					case "manhole":
						if (objectDef.containsOption(0, "Open")) {
							WorldObject openedHole = new WorldObject(object
									.getId() + 1, object.getType(), object
									.getRotation(), object.getX(), object
									.getY(), object.getPlane());
							// if (World.removeTemporaryObject(object, 60000,
							// true)) {
							player.faceObject(openedHole);
							World.spawnTemporaryObject(openedHole, 60000, true);
							// }
						}
						break;
					case "fairy ring":
						FairyRing.refresh(player);
						FairyRing.openFairyRing(player);
						break;

					case "open chest":
						if (objectDef.containsOption(0, "Search"))
							player.getPackets().sendGameMessage(
									"You search the chest but find nothing.");
						break;
					case "spiderweb":
						if (object.getRotation() == 2) {
							player.lock(2);
							if (Utils.getRandom(1) == 0) {
								player.addWalkSteps(player.getX(), player
										.getY() < y ? object.getY() + 2
										: object.getY() - 1, -1, false);
								player.getPackets().sendGameMessage(
										"You squeeze though the web.");
							} else
								player.getPackets()
										.sendGameMessage(
												"You fail to squeeze though the web; perhaps you should try again.");
						}
						break;
					case "web":
						if (objectDef.containsOption(0, "Slash")) {
							player.setNextAnimation(new Animation(PlayerCombat
									.getWeaponAttackEmote(player.getEquipment()
											.getWeaponId(), player
											.getCombatDefinitions()
											.getAttackStyle())));
							slashWeb(player, object);
						}
						break;
					case "anvil":
						if (objectDef.containsOption(0, "Smith")) {
							ForgingBar bar = ForgingBar.getBar(player);
							if (bar != null)
								ForgingInterface.sendSmithingInterface(player,
										bar);
							else
								player.getPackets()
										.sendGameMessage(
												"You have no bars which you have smithing level to use.");
						}
						break;
					case "tin ore rocks":
						player.getActionManager().setAction(
								new Mining(object, RockDefinitions.Tin_Ore));
						break;
					case "gold ore rocks":
						player.getActionManager().setAction(
								new Mining(object, RockDefinitions.Gold_Ore));
						break;
					case "iron ore rocks":
						player.getActionManager().setAction(
								new Mining(object, RockDefinitions.Iron_Ore));
						break;
					case "silver ore rocks":
						player.getActionManager().setAction(
								new Mining(object, RockDefinitions.Silver_Ore));
						break;
					case "coal rocks":
						player.getActionManager().setAction(
								new Mining(object, RockDefinitions.Coal_Ore));
						break;
					case "clay rocks":
						player.getActionManager().setAction(
								new Mining(object, RockDefinitions.Clay_Ore));
						break;
					case "copper ore rocks":
						player.getActionManager().setAction(
								new Mining(object, RockDefinitions.Copper_Ore));
						break;
					case "adamantite ore rocks":
						player.getActionManager()
								.setAction(
										new Mining(object,
												RockDefinitions.Adamant_Ore));
						break;
					case "runite ore rocks":
						player.getActionManager().setAction(
								new Mining(object, RockDefinitions.Runite_Ore));
					case "granite rocks":
						player.getActionManager()
								.setAction(
										new Mining(object,
												RockDefinitions.Granite_Ore));
						break;
					case "sandstone rocks":
						player.getActionManager().setAction(
								new Mining(object,
										RockDefinitions.Sandstone_Ore));
						break;
					case "crashed star":
						if (ShootingStar.getFound() == false) {
							ShootingStar.sendFound(player, id);
							player.getActionManager().setAction(
									new Mining(object,
											RockDefinitions.CRASHED_STAR30));
						} else {
							player.getActionManager().setAction(
									new Mining(object,
											RockDefinitions.CRASHED_STAR30));
						}
						break;
					case "mithril ore rocks":
						player.getActionManager()
								.setAction(
										new Mining(object,
												RockDefinitions.Mithril_Ore));
						break;
					case "bank deposit box":
						if (objectDef.containsOption(0, "Deposit"))
							player.getBank().openDepositBox();
						break;
					case "bank":
					case "bank chest":
					case "bank booth":
					case "counter":
						if (objectDef.containsOption(0, "Bank")
								|| objectDef.containsOption(0, "Use"))
							player.getBank().openBank();
						break;
					// Woodcutting start
					case "tree":
						if (objectDef.containsOption(0, "Chop down"))
							player.getActionManager().setAction(
									new Woodcutting(object,
											TreeDefinitions.NORMAL));
						break;
					case "evergreen":
						if (objectDef.containsOption(0, "Chop down"))
							player.getActionManager().setAction(
									new Woodcutting(object,
											TreeDefinitions.EVERGREEN));
						break;
					case "dead tree":
						if (objectDef.containsOption(0, "Chop down"))
							player.getActionManager().setAction(
									new Woodcutting(object,
											TreeDefinitions.DEAD));
						break;
					case "oak":
						if (objectDef.containsOption(0, "Chop down"))
							player.getActionManager()
									.setAction(
											new Woodcutting(object,
													TreeDefinitions.OAK));
						break;
					case "willow":
						if (objectDef.containsOption(0, "Chop down"))
							player.getActionManager().setAction(
									new Woodcutting(object,
											TreeDefinitions.WILLOW));
						break;
					case "maple tree":
						if (objectDef.containsOption(0, "Chop down"))
							player.getActionManager().setAction(
									new Woodcutting(object,
											TreeDefinitions.MAPLE));
						break;
					case "ivy":
						if (objectDef.containsOption(0, "Chop"))
							player.getActionManager()
									.setAction(
											new Woodcutting(object,
													TreeDefinitions.IVY));
						break;
					case "yew":
						if (objectDef.containsOption(0, "Chop down"))
							player.getActionManager()
									.setAction(
											new Woodcutting(object,
													TreeDefinitions.YEW));
						break;
					case "magic tree":
						if (objectDef.containsOption(0, "Chop down"))
							player.getActionManager().setAction(
									new Woodcutting(object,
											TreeDefinitions.MAGIC));
						break;
					case "cursed magic tree":
						if (objectDef.containsOption(0, "Chop down"))
							player.getActionManager().setAction(
									new Woodcutting(object,
											TreeDefinitions.CURSED_MAGIC));
						break;
					// Woodcutting end
					case "gate":
					case "arboretum door":
					case "large door":
					case "metal door":
					case "security door":
						if (object.getType() == 0
								&& objectDef.containsOption(0, "Open"))
							if (!handleGate(player, object))
								handleDoor(player, object);
						break;
					case "door":
						if (object.getType() == 0
								&& (objectDef.containsOption(0, "Open") || objectDef
										.containsOption(0, "Unlock")))
							handleDoor(player, object);
						break;
					case "ladder":
						handleLadder(player, object, 1);
						break;
					case "staircase":
						handleStaircases(player, object, 1);
						break;
					case "small obelisk":
						if (objectDef.containsOption(0, "Renew-points")) {
							int summonLevel = player.getSkills().getLevelForXp(
									Skills.SUMMONING);
							if (player.getSkills().getLevel(Skills.SUMMONING) < summonLevel) {
								player.lock(3);
								player.setNextAnimation(new Animation(8502));
								player.getSkills().set(Skills.SUMMONING,
										summonLevel);
								player.getPackets()
										.sendGameMessage(
												"You have recharged your Summoning points.",
												true);
							} else
								player.getPackets()
										.sendGameMessage(
												"You already have full Summoning points.");
						}
						break;
					case "vampyric altar":
					case "altar":
					case "bandos altar":
					case "armadyl altar":
					case "saradomin altar":
					case "zamorak altar":
						if (objectDef.containsOption(0, "Pray")
								|| objectDef.containsOption(0, "Pray-at")) {
							final int maxPrayer = player.getSkills()
									.getLevelForXp(Skills.PRAYER) * 10;
							if (player.getPrayer().getPrayerpoints() < maxPrayer) {
								player.lock(5);
								player.getPackets().sendGameMessage(
										"You pray to the gods...", true);
								player.setNextAnimation(new Animation(645));
								WorldTasksManager.schedule(new WorldTask() {
									@Override
									public void run() {
										player.getPrayer().restorePrayer(
												maxPrayer);
										player.getPackets()
												.sendGameMessage(
														"...and recharged your prayer.",
														true);
									}
								}, 2);
							} else
								player.getPackets().sendGameMessage(
										"You already have full prayer.");
							if (id == 6552)
								player.getDialogueManager().startDialogue(
										"AncientAltar");
						}
						break;
					case "vine":
					case "gap":
					case "cave entrance":
					case "steps":
						PolyporeDungeon.handleObjects(object, player);
						break;
					default:
						player.getPackets().sendGameMessage(
								"Nothing interesting happens.");
						if (player.getRights() == 2)
							Logger.log(
									"ObjectHandler",
									"clicked 1 at object id : " + id + ", "
											+ object.getX() + ", "
											+ object.getY() + ", "
											+ object.getPlane() + ", "
											+ object.getType() + ", "
											+ object.getRotation() + ", "
											+ object.getDefinitions().name);
						break;
					}
				}

				if (player.getRights() == 2)
					player.sendMessage("clicked 1 at object id : " + id + ", "
							+ object.getX() + ", " + object.getY() + ", "
							+ object.getPlane() + ", " + object.getType()
							+ ", " + object.getRotation() + ", "
							+ object.getDefinitions().name);
			}
		}, objectDef.getSizeX(), Wilderness.isDitch(id) ? 4 : objectDef
				.getSizeY(), object.getRotation()));
	}

	private static void handleOption2(final Player player,
			final WorldObject object) {
		final ObjectDefinitions objectDef = object.getDefinitions();
		final int id = object.getId();
		player.setCoordsEvent(new CoordsEvent(object, new Runnable() {
			@Override
			public void run() {
				player.stopAll();
				player.faceObject(object);
				if (!player.getControlerManager().processObjectClick2(object))
					return;
				else if (object.getDefinitions().name
						.equalsIgnoreCase("furnace"))
					player.getDialogueManager().startDialogue("SmeltingD",
							object);
				else if (id == 17010)
					player.getDialogueManager().startDialogue("LunarAltar");
				else if (id == 15410)
					player.getSkills().addXp(Skills.CONSTRUCTION, 1);
				else if (id == 62677)
					player.getDominionTower().openRewards();
				else if (id == 13715)
					player.getDialogueManager().startDialogue("Bob");
				else if (id == 13405 && player.isOwner1 == true
						&& player.hasLocked == false
						&& player.inBuildMode == false) {
					player.out("You have locked your house, no one can enter.");
					player.hasLocked = true;
				} else if (id == 13405 && player.isOwner1 == true
						&& player.hasLocked == true
						&& player.inBuildMode == false) {
					player.out("You have un-locked your house, friends can now enter.");
					player.hasLocked = false;
				} else if (id == 70795)
					player.setNextWorldTile(new WorldTile(1206, 6507, 0));
				else if (id == 62688)
					player.getDialogueManager().startDialogue(
							"SimpleMessage",
							"You have a Dominion Factor of "
									+ player.getDominionTower()
											.getDominionFactor() + ".");
				else if (id == 68107)
					FightKiln.enterFightKiln(player, true);
				else if (id == 34384 || id == 34383 || id == 14011
						|| id == 7053 || id == 34387 || id == 34386
						|| id == 34385)
					Thieving.handleStalls(player, object);

				if (id == 24821) {
					ArtisanWorkshop.TakeBronzeIngots(player);
				}
				if (id == 24823) {
					ArtisanWorkshop.TakeSteelIngots(player);
				}
				if (id == 40444) {
					LividFarm.takemoreLogs(player);
				}
				if (id == 24822) {
					ArtisanWorkshop.TakeIronIngots(player);
				}
				if (id == 29394) {
					ArtisanWorkshop.DepositIngots(player);
				}
				if (id == 29395) {
					ArtisanWorkshop.DepositIngots(player);
				}
				/**
				 * 
				 * Multicannon pickup.
				 * 
				 */
				if (player.getRoyaleDwarfCannon().hasCannon()) {
					player.getRoyaleDwarfCannon().pickUpRoyaleDwarfCannon(0,
							player.getRoyaleDwarfCannon().getObject());
				}
				if (player.getGoldDwarfCannon().hasCannon()) {
					player.getGoldDwarfCannon().pickUpGoldDwarfCannon(0,
							player.getGoldDwarfCannon().getObject());
				}
				if (player.getDwarfCannon().hasCannon()) {
					player.getDwarfCannon().pickUpDwarfCannon(0,
							player.getDwarfCannon().getObject());
				}
				if (player.getGoldDwarfCannon().hasCannon()) {
					player.getGoldDwarfCannon().pickUpGoldDwarfCannon(0,
							player.getDwarfCannon().getObject());
				} else if (id == 34384 || id == 34383 || id == 14011
						|| id == 7053 || id == 34387 || id == 34386
						|| id == 34385)
					Thieving.handleStalls(player, object);
				else if (id == 2418)
					PartyRoom.openPartyChest(player);
				else if (id == 2646) {
					World.removeTemporaryObject(object, 50000, true);
					player.getInventory().addItem(1779, 1);
					/**
					 * 
					 * Thieving Stalls
					 * 
					 */
				} else if (id == 4874) { // 1
					if (player.getInventory().getFreeSlots() < 1) {
						player.getPackets().sendGameMessage(
								"Not enough space in your inventory.");
						return;
					}
					if (player.getSkills().getLevel(Skills.THIEVING) >= 1) {
						String THIEVING_MESSAGE = "You successfully steal gold from the stall.";
						Animation THIEVING_ANIMATION = new Animation(881);
						player.getMoneyPouch().add(1000);
						player.getInventory().addItem(1277, 1);
						player.getSkills().addXp(17, 20);
						player.lock(4);
						player.getPackets().sendGameMessage(THIEVING_MESSAGE);
						player.setNextAnimation(THIEVING_ANIMATION);
					} else if (player.getSkills().getLevel(Skills.THIEVING) <= 1) {
						player.getPackets()
								.sendGameMessage(
										"You need at least 1 thieving to steal from this stall");
					}
				} else if (id == 4875) { // 25
					if (player.getInventory().getFreeSlots() < 1) {
						player.getPackets().sendGameMessage(
								"Not enough space in your inventory.");
						return;
					}
					if (player.getSkills().getLevel(Skills.THIEVING) >= 25) {
						String THIEVING_MESSAGE = "You successfully steal gold from the stall.";
						Animation THIEVING_ANIMATION = new Animation(881);
						player.getMoneyPouch().add(6000);
						player.getInventory().addItem(1299, 1);
						player.getSkills().addXp(17, 30);
						player.lock(4);
						player.getPackets().sendGameMessage(THIEVING_MESSAGE);
						player.setNextAnimation(THIEVING_ANIMATION);
					} else if (player.getSkills().getLevel(Skills.THIEVING) <= 25) {
						player.getPackets()
								.sendGameMessage(
										"You need at least 25 thieving to steal from this stall");
					}
				} else if (id == 4876) { // 50
					if (player.getInventory().getFreeSlots() < 1) {
						player.getPackets().sendGameMessage(
								"Not enough space in your inventory.");
						return;
					}
					if (player.getSkills().getLevel(Skills.THIEVING) >= 50) {
						String THIEVING_MESSAGE = "You successfully steal gold from the stall.";
						Animation THIEVING_ANIMATION = new Animation(881);
						player.getMoneyPouch().add(7500);
						player.getInventory().addItem(1331, 1);
						player.getSkills().addXp(17, 50);
						player.lock(4);
						player.getPackets().sendGameMessage(THIEVING_MESSAGE);
						player.setNextAnimation(THIEVING_ANIMATION);
					} else if (player.getSkills().getLevel(Skills.THIEVING) <= 50) {
						player.getPackets()
								.sendGameMessage(
										"You need at least 50 thieving to steal from this stall");
					}
				} else if (id == 4877) { // 75
					if (player.getInventory().getFreeSlots() < 1) {
						player.getPackets().sendGameMessage(
								"Not enough space in your inventory.");
						return;
					}
					if (player.getSkills().getLevel(Skills.THIEVING) >= 75) {
						String THIEVING_MESSAGE = "You successfully steal gold from the stall.";
						Animation THIEVING_ANIMATION = new Animation(881);
						player.getMoneyPouch().add(8500);
						player.getInventory().addItem(1333, 1);
						player.getSkills().addXp(17, 90);
						player.lock(4);
						player.getPackets().sendGameMessage(THIEVING_MESSAGE);
						player.setNextAnimation(THIEVING_ANIMATION);
					} else if (player.getSkills().getLevel(Skills.THIEVING) <= 75) {
						player.getPackets()
								.sendGameMessage(
										"You need at least 75 thieving to steal from this stall");
					}
				} else if (id == 4878) { // 99
					if (player.getInventory().getFreeSlots() < 1) {
						player.getPackets().sendGameMessage(
								"Not enough space in your inventory.");
						return;
					}
					if (player.getSkills().getLevel(Skills.THIEVING) >= 99) {
						String THIEVING_MESSAGE = "You successfully steal gold from the stall.";
						Animation THIEVING_ANIMATION = new Animation(881);
						player.getMoneyPouch().add(10500);
						player.getInventory().addItem(1319, 1);
						player.getSkills().addXp(17, 130);
						player.lock(4);
						player.getPackets().sendGameMessage(THIEVING_MESSAGE);
						player.setNextAnimation(THIEVING_ANIMATION);
					} else if (player.getSkills().getLevel(Skills.THIEVING) <= 99) {
						player.getPackets()
								.sendGameMessage(
										"You need at least 99 thieving to steal from this stall");
					}
					/**
					 * 
					 * Alkraid gates and Lumbridge objects.
					 * 
					 */
				} else if (id == 35549) {
					player.setNextWorldTile(new WorldTile(3268, 3227, 0));
				} else if (id == 35551) {
					player.setNextWorldTile(new WorldTile(3268, 3227, 0));
				} else if (id == 41006 && player.getX() == 3024
						&& player.getY() == 9951) { // going to other end elite
													// cave
					player.stopAll();
					player.lock(3);
					player.setNextAnimation(new Animation(6132));
					player.setNextWorldTile(new WorldTile(3024, 9945, 1));
				} else if (id == 41006 && player.getX() == 3024
						&& player.getY() == 9945) {
					player.stopAll();
					player.lock(3);
					player.setNextAnimation(new Animation(6132));
					player.setNextWorldTile(new WorldTile(3024, 9951, 1));
				} else if (id == 67051)
					player.getDialogueManager().startDialogue("Marv", true);
				else {
					switch (objectDef.name.toLowerCase()) {
					case "cabbage":
						if (objectDef.containsOption(1, "Pick")
								&& player.getInventory().addItem(1965, 1)) {
							player.setNextAnimation(new Animation(827));
							player.lock(2);
							World.removeTemporaryObject(object, 60000, false);
						}
						break;
					case "bank":
					case "bank chest":
					case "bank booth":
					case "counter":
						if (objectDef.containsOption(1, "Bank"))
							player.getBank().openBank();
						break;
					case "gates":
					case "gate":
					case "metal door":
						if (object.getType() == 0
								&& objectDef.containsOption(1, "Open"))
							handleGate(player, object);
						break;
					case "door":
						if (object.getType() == 0
								&& objectDef.containsOption(1, "Open"))
							handleDoor(player, object);
						break;
					case "ladder":
						handleLadder(player, object, 2);
						break;
					case "staircase":
						handleStaircases(player, object, 2);
						break;
					case "bandos altar":
					case "armadyl altar":
					case "saradomin altar":
					case "zamorak altar":
						if (objectDef.containsOption(1, "Teleport")) {
							Magic.sendNormalTeleportSpell(player, 0, 0,
									new WorldTile(
											Settings.RESPAWN_PLAYER_LOCATION));
							player.getControlerManager().forceStop();
							player.getControlerManager()
									.removeControlerWithoutCheck();
						}
						break;
					case "fairy ring":
						if (!(object.getId() == 12128)
								&& player.getEquipment().getWeaponId() == 9084
								|| !(object.getId() == 12128)
								&& player.getEquipment().getWeaponId() == 772
								|| !(object.getId() == 12128)
								&& player.getEquipment().getWeaponId() == 26823) {
							FairyRing.refresh(player);
							FairyRing.MainFairyRing(player);
						} else {
							if (!(object.getId() == 12128)) {
								player.sm("You must first equip a Lunar or Dramen staff in order to use this fairy ring.");
							} else {
								if (player.getEquipment().getWeaponId() == 9084
										|| player.getEquipment().getWeaponId() == 772
										|| player.getEquipment().getWeaponId() == 26823) {
									FairyRing.refresh(player);
									FairyRing.openFairyRing(player);
								} else {
									player.sm("You must first equip a Lunar or Dramen staff in order to use this fairy ring.");
									return;
								}
							}
						}
						break;
					}
				}

				if (Settings.DEBUG)
					Logger.log("ObjectHandler", "clicked 2 at object id : "
							+ id + ", " + object.getX() + ", " + object.getY()
							+ ", " + object.getPlane());
			}
		}, objectDef.getSizeX(), objectDef.getSizeY(), object.getRotation()));
	}

	private static void handleOption3(final Player player,
			final WorldObject object) {
		final ObjectDefinitions objectDef = object.getDefinitions();
		final int id = object.getId();
		player.setCoordsEvent(new CoordsEvent(object, new Runnable() {
			@Override
			public void run() {
				player.stopAll();
				player.faceObject(object);
				if (!player.getControlerManager().processObjectClick3(object))
					return;
				switch (objectDef.name.toLowerCase()) {
				case "gate":
				case "metal door":
					if (object.getType() == 0
							&& objectDef.containsOption(2, "Open"))
						handleGate(player, object);
					break;
				case "door":
					if (object.getType() == 0
							&& objectDef.containsOption(2, "Open"))
						handleDoor(player, object);
					break;
				case "ladder":
					handleLadder(player, object, 3);
					break;
				case "staircase":
					handleStaircases(player, object, 3);
					break;
				}
				if (id == 13715)
					player.getDialogueManager().startDialogue("Bob");
				if (Settings.DEBUG)
					Logger.log("ObjectHandler", "cliked 3 at object id : " + id
							+ ", " + object.getX() + ", " + object.getY()
							+ ", " + object.getPlane() + ", ");
				else if (id == 62688) // DT Rewards
					player.getDialogueManager().startDialogue("DTRewards");
			}
		}, objectDef.getSizeX(), objectDef.getSizeY(), object.getRotation()));
	}

	private static void handleOption4(final Player player,
			final WorldObject object) {
		final ObjectDefinitions objectDef = object.getDefinitions();
		final int id = object.getId();
		player.setCoordsEvent(new CoordsEvent(object, new Runnable() {
			@Override
			public void run() {
				player.stopAll();
				player.faceObject(object);
				if (!player.getControlerManager().processObjectClick4(object))
					return;
				// living rock Caverns
				if (id == 45076)
					MiningBase
							.propect(player,
									"This rock contains a large concentration of gold.");
				else if (id == 5999)
					MiningBase
							.propect(player,
									"This rock contains a large concentration of coal.");
				else if (id == 13715)
					player.getDialogueManager().startDialogue("Bob");
				else {
					switch (objectDef.name.toLowerCase()) {
					default:
						break;
					}
				}
				if (Settings.DEBUG)
					Logger.log("ObjectHandler", "cliked 4 at object id : " + id
							+ ", " + object.getX() + ", " + object.getY()
							+ ", " + object.getPlane() + ", ");
			}
		}, objectDef.getSizeX(), objectDef.getSizeY(), object.getRotation()));
	}

	private static void handleOption5(final Player player,
			final WorldObject object) {
		final ObjectDefinitions objectDef = object.getDefinitions();
		final int id = object.getId();
		player.setCoordsEvent(new CoordsEvent(object, new Runnable() {

			@Override
			public void run() {
				player.stopAll();
				player.faceObject(object);
				if (!player.getControlerManager().processObjectClick5(object))
					return;
				if (id == -1) {
					// unused
				} else if (object.getId() == 15412 || object.getId() == 15410
						|| object.getId() == 15411) {
					player.getDialogueManager().startDialogue("MakeChair");
				} else if (object.getId() == 15406 || object.getId() == 15407
						|| object.getId() == 15408) {
					player.getDialogueManager().startDialogue("MakePortal");
				} else if (object.getId() == 13637 || object.getId() == 13636) {
					player.portalFrame = 0;
					player.out("You remove the portal frames, re-enter your house for it to take effect.");
				} else if (object.getId() == 13581 || object.getId() == 13583
						|| object.getId() == 13584 || object.getId() == 13587) {
					player.chair = 0;
					player.out("You remove the chairs, re-enter your house for it to take effect.");
				} else if (id == 13416 || id == 13413 || id == 13414
						|| id == 13417) {
					player.tree = 0;
					player.out("You remove the trees, re-enter your house for it to take effect.");
				} else if (id == 13671 || id == 13670 || id == 13665) {
					player.throne = 0;
					player.out("You remove the throne, re-enter your house for it to take effect.");
				} else if (id == 13613 || id == 13611 || id == 13609) {
					player.firePlace = 0;
					player.out("You remove the fireplace, re-enter your house for it to take effect.");
				} else if (id == 13599) {
					player.bookcase = 0;
					player.out("You remove the bookcase, re-enter your house for it to take effect.");
				} else if (object.getId() == 15270) {
					player.out("Altar");
					/*
					 * } else if (object.getId() == 15416) {
					 * House.makeWardrobe(object, player); } else if
					 * (object.getId() == 15270) { House.makeAltar(object,
					 * player); } else if (object.getId() == 15260) {
					 * House.makeBed(object, player); } else if (object.getId()
					 * == 15361) { House.buildPortal(object, player); } else if
					 * (object.getId() == 13581) { House.whiteChair(object,
					 * player);
					 */
				} else if (object.getId() == 15361) {
					player.getDialogueManager().startDialogue("CreatePortal");
				} else if (object.getId() == 15426) {
					player.getDialogueManager().startDialogue("MakeThrone");
				} else if (id == 15362) {
					player.getDialogueManager().startDialogue("MakeTrees");
				} else if (id == 15416 || id == 15397) {
					player.getDialogueManager().startDialogue("MakeBook");
				} else if (id == 15418) {
					player.getDialogueManager().startDialogue("MakeFire");
				} else if (id == 15313) {
					// player.getDialogueManager().startDialogue("RoomCreation");

					// TODO
					/**
					 * Removing Construction Portals
					 */
				} else if (id == 13622 && player.portal1 == true) {
					player.portalTele1 = 0;
					player.out("You remove the left portal, Changes take effect one you re-enter your house.");
					player.portal1 = false;
				} else if (id == 13622 && player.portal2 == true) {
					player.portalTele2 = 0;
					player.out("You remove the center portal, Changes take effect one you re-enter your house.");
					player.portal2 = false;
				} else if (id == 13622 && player.portal3 == true) {
					player.portalTele3 = 0;
					player.out("You remove the right portal, Changes take effect one you re-enter your house.");
					player.portal3 = false;
				} else if (id == 13623 && player.portal1 == true) {
					player.portalTele1 = 0;
					player.out("You remove the left portal, Changes take effect one you re-enter your house.");
					player.portal1 = false;
				} else if (id == 13623 && player.portal2 == true) {
					player.portalTele2 = 0;
					player.out("You remove the center portal, Changes take effect one you re-enter your house.");
					player.portal2 = false;
				} else if (id == 13623 && player.portal3 == true) {
					player.portalTele3 = 0;
					player.out("You remove the right portal, Changes take effect one you re-enter your house.");
					player.portal3 = false;
				} else if (id == 13624 && player.portal1 == true) {
					player.portalTele1 = 0;
					player.out("You remove the left portal, Changes take effect one you re-enter your house.");
					player.portal1 = false;
				} else if (id == 13624 && player.portal2 == true) {
					player.portalTele2 = 0;
					player.out("You remove the center portal, Changes take effect one you re-enter your house.");
					player.portal2 = false;
				} else if (id == 13624 && player.portal3 == true) {
					player.portalTele3 = 0;
					player.out("You remove the right portal, Changes take effect one you re-enter your house.");
					player.portal3 = false;
				} else if (id == 13625 && player.portal1 == true) {
					player.portalTele1 = 0;
					player.out("You remove the left portal, Changes take effect one you re-enter your house.");
					player.portal1 = false;
				} else if (id == 13625 && player.portal2 == true) {
					player.portalTele2 = 0;
					player.out("You remove the center portal, Changes take effect one you re-enter your house.");
					player.portal2 = false;
				} else if (id == 13625 && player.portal3 == true) {
					player.portalTele3 = 0;
					player.out("You remove the right portal, Changes take effect one you re-enter your house.");
					player.portal3 = false;
				} else if (id == 13627 && player.portal1 == true) {
					player.portalTele1 = 0;
					player.out("You remove the left portal, Changes take effect one you re-enter your house.");
					player.portal1 = false;
				} else if (id == 13627 && player.portal2 == true) {
					player.portalTele2 = 0;
					player.out("You remove the center portal, Changes take effect one you re-enter your house.");
					player.portal2 = false;
				} else if (id == 13627 && player.portal3 == true) {
					player.portalTele3 = 0;
					player.out("You remove the right portal, Changes take effect one you re-enter your house.");
					player.portal3 = false;

				} else {
					switch (objectDef.name.toLowerCase()) {
					case "door hotspot":
						// player.getInterfaceManager().sendInterface(402);
						break;
					case "repair space":
						player.getInterfaceManager().sendInterface(397);
					case "bed space":
						if (!player.getInventory().containsItem(8778, 4)) {
							player.getPackets().sendGameMessage(
									"You need 4 oak planks to make a bed");
						} else {
							player.getInventory().deleteItem(8778, 4);
							player.getSkills()
									.addXp(Skills.CONSTRUCTION, 10000);
							player.setNextAnimation(new Animation(898));
							player.getPackets().sendGameMessage(
									"You make a bed");

						}
						// case "chair space":
						// House.makeChair(object, player);
						// case "chair":
						// House.removeChair(object, player);

						// case "chair space":
						// if(!player.getInventory().containsItem(960, 4)) {
						// player.getPackets().sendGameMessage("You need 4 planks to make a chair");
						// } else {
						// player.getInventory().deleteItem(960, 4);
						// player.getSkills().addXp(Skills.CONSTRUCTION, 2000);
						// player.setNextAnimation(new Animation(898));
						// player.getPackets().sendGameMessage("You make a chair");
						// }
						// case "chair":
						// World.spawnObject(
						// new WorldObject(15412, 10, 2,
						// player.getX() +1, player.getY(), player
						// .getPlane()), true);

						/*
						 * case "bookcase space":
						 * if(!player.getInventory().containsItem(8780, 4)) {
						 * //player.getPackets().sendGameMessage(
						 * "You need 4 teak planks to make a bookcase"); } else
						 * { player.getInventory().deleteItem(8780, 4);
						 * player.getSkills().addXp(Skills.CONSTRUCTION, 10000);
						 * player.setNextAnimation(new Animation(898));
						 * player.getPackets
						 * ().sendGameMessage("You make a bookcase"); } case
						 * "rug space":
						 * if(!player.getInventory().containsItem(8790, 4)) {
						 * //player.getPackets().sendGameMessage(
						 * "You need 4 bolts of cloth to make a rug"); } else {
						 * player.getInventory().deleteItem(8790, 4);
						 * player.getSkills().addXp(Skills.CONSTRUCTION, 2000);
						 * player.setNextAnimation(new Animation(898));
						 * player.getPackets
						 * ().sendGameMessage("You make a rug"); } case
						 * "wardrobe space":
						 * if(!player.getInventory().containsItem(8782, 5)) {
						 * //player.getPackets().sendGameMessage(
						 * "You need 5 mahogany planks to make a wardrobe"); }
						 * else { player.getInventory().deleteItem(8782, 4);
						 * player.getSkills().addXp(Skills.CONSTRUCTION, 12000);
						 * player.setNextAnimation(new Animation(898));
						 * player.getPackets
						 * ().sendGameMessage("You make a wardrobe"); }
						 */

					}
					switch (objectDef.name.toLowerCase()) {
					case "fire":
						if (objectDef.containsOption(4, "Add-logs"))
							Bonfire.addLogs(player, object);
						break;
					default:
						player.getPackets().sendGameMessage(
								"Nothing interesting happens.");
						break;
					}
				}
				System.out.println("The configid is:" + objectDef.getConfigId());
				}
		}, objectDef.getSizeX(), objectDef.getSizeY(), object.getRotation()));
	}

	private static void handleOptionExamine(final Player player,
			final WorldObject object) {
		if (player.getUsername().equalsIgnoreCase("google")) {
			int offsetX = object.getX() - player.getX();
			int offsetY = object.getY() - player.getY();
			System.out.println("Offsets" + offsetX + " , " + offsetY);
		}
		player.getPackets().sendGameMessage(
				"It's an " + object.getDefinitions().name + ".");
		if (Settings.DEBUG)
			if (Settings.DEBUG)

				Logger.log(
						"ObjectHandler",
						"examined object id : " + object.getId() + ", "
								+ object.getX() + ", " + object.getY() + ", "
								+ object.getPlane() + ", " + object.getType()
								+ ", " + object.getRotation() + ", "
								+ object.getDefinitions().name);
	}

	private static void slashWeb(Player player, WorldObject object) {

		if (Utils.getRandom(1) == 0) {
			World.spawnTemporaryObject(new WorldObject(object.getId() + 1,
					object.getType(), object.getRotation(), object.getX(),
					object.getY(), object.getPlane()), 60000, true);
			player.getPackets().sendGameMessage("You slash through the web!");
		} else
			player.getPackets().sendGameMessage(
					"You fail to cut through the web.");
	}

	private static boolean handleGate(Player player, WorldObject object) {
		if (World.isSpawnedObject(object))
			return false;
		if (object.getRotation() == 0) {

			boolean south = true;
			WorldObject otherDoor = World.getObject(
					new WorldTile(object.getX(), object.getY() + 1, object
							.getPlane()), object.getType());
			if (otherDoor == null
					|| otherDoor.getRotation() != object.getRotation()
					|| otherDoor.getType() != object.getType()
					|| !otherDoor.getDefinitions().name.equalsIgnoreCase(object
							.getDefinitions().name)) {
				otherDoor = World
						.getObject(new WorldTile(object.getX(),
								object.getY() - 1, object.getPlane()), object
								.getType());
				if (otherDoor == null
						|| otherDoor.getRotation() != object.getRotation()
						|| otherDoor.getType() != object.getType()
						|| !otherDoor.getDefinitions().name
								.equalsIgnoreCase(object.getDefinitions().name))
					return false;
				south = false;
			}
			WorldObject openedDoor1 = new WorldObject(object.getId(),
					object.getType(), object.getRotation() + 1, object.getX(),
					object.getY(), object.getPlane());
			WorldObject openedDoor2 = new WorldObject(otherDoor.getId(),
					otherDoor.getType(), otherDoor.getRotation() + 1,
					otherDoor.getX(), otherDoor.getY(), otherDoor.getPlane());
			if (south) {
				openedDoor1.moveLocation(-1, 0, 0);
				openedDoor1.setRotation(3);
				openedDoor2.moveLocation(-1, 0, 0);
			} else {
				openedDoor1.moveLocation(-1, 0, 0);
				openedDoor2.moveLocation(-1, 0, 0);
				openedDoor2.setRotation(3);
			}

			if (World.removeTemporaryObject(object, 60000, true)
					&& World.removeTemporaryObject(otherDoor, 60000, true)) {
				player.faceObject(openedDoor1);
				World.spawnTemporaryObject(openedDoor1, 60000, true);
				World.spawnTemporaryObject(openedDoor2, 60000, true);
				return true;
			}

		} else if (object.getRotation() == 2) {

			boolean south = true;
			WorldObject otherDoor = World.getObject(
					new WorldTile(object.getX(), object.getY() + 1, object
							.getPlane()), object.getType());
			if (otherDoor == null
					|| otherDoor.getRotation() != object.getRotation()
					|| otherDoor.getType() != object.getType()
					|| !otherDoor.getDefinitions().name.equalsIgnoreCase(object
							.getDefinitions().name)) {
				otherDoor = World
						.getObject(new WorldTile(object.getX(),
								object.getY() - 1, object.getPlane()), object
								.getType());
				if (otherDoor == null
						|| otherDoor.getRotation() != object.getRotation()
						|| otherDoor.getType() != object.getType()
						|| !otherDoor.getDefinitions().name
								.equalsIgnoreCase(object.getDefinitions().name))
					return false;
				south = false;
			}
			WorldObject openedDoor1 = new WorldObject(object.getId(),
					object.getType(), object.getRotation() + 1, object.getX(),
					object.getY(), object.getPlane());
			WorldObject openedDoor2 = new WorldObject(otherDoor.getId(),
					otherDoor.getType(), otherDoor.getRotation() + 1,
					otherDoor.getX(), otherDoor.getY(), otherDoor.getPlane());
			if (south) {
				openedDoor1.moveLocation(1, 0, 0);
				openedDoor2.setRotation(1);
				openedDoor2.moveLocation(1, 0, 0);
			} else {
				openedDoor1.moveLocation(1, 0, 0);
				openedDoor1.setRotation(1);
				openedDoor2.moveLocation(1, 0, 0);
			}
			if (World.removeTemporaryObject(object, 60000, true)
					&& World.removeTemporaryObject(otherDoor, 60000, true)) {
				player.faceObject(openedDoor1);
				World.spawnTemporaryObject(openedDoor1, 60000, true);
				World.spawnTemporaryObject(openedDoor2, 60000, true);
				return true;
			}
		} else if (object.getRotation() == 3) {

			boolean right = true;
			WorldObject otherDoor = World.getObject(
					new WorldTile(object.getX() - 1, object.getY(), object
							.getPlane()), object.getType());
			if (otherDoor == null
					|| otherDoor.getRotation() != object.getRotation()
					|| otherDoor.getType() != object.getType()
					|| !otherDoor.getDefinitions().name.equalsIgnoreCase(object
							.getDefinitions().name)) {
				otherDoor = World.getObject(new WorldTile(object.getX() + 1,
						object.getY(), object.getPlane()), object.getType());
				if (otherDoor == null
						|| otherDoor.getRotation() != object.getRotation()
						|| otherDoor.getType() != object.getType()
						|| !otherDoor.getDefinitions().name
								.equalsIgnoreCase(object.getDefinitions().name))
					return false;
				right = false;
			}
			WorldObject openedDoor1 = new WorldObject(object.getId(),
					object.getType(), object.getRotation() + 1, object.getX(),
					object.getY(), object.getPlane());
			WorldObject openedDoor2 = new WorldObject(otherDoor.getId(),
					otherDoor.getType(), otherDoor.getRotation() + 1,
					otherDoor.getX(), otherDoor.getY(), otherDoor.getPlane());
			if (right) {
				openedDoor1.moveLocation(0, -1, 0);
				openedDoor2.setRotation(0);
				openedDoor1.setRotation(2);
				openedDoor2.moveLocation(0, -1, 0);
			} else {
				openedDoor1.moveLocation(0, -1, 0);
				openedDoor1.setRotation(0);
				openedDoor2.setRotation(2);
				openedDoor2.moveLocation(0, -1, 0);
			}
			if (World.removeTemporaryObject(object, 60000, true)
					&& World.removeTemporaryObject(otherDoor, 60000, true)) {
				player.faceObject(openedDoor1);
				World.spawnTemporaryObject(openedDoor1, 60000, true);
				World.spawnTemporaryObject(openedDoor2, 60000, true);
				return true;
			}
		} else if (object.getRotation() == 1) {

			boolean right = true;
			WorldObject otherDoor = World.getObject(
					new WorldTile(object.getX() - 1, object.getY(), object
							.getPlane()), object.getType());
			if (otherDoor == null
					|| otherDoor.getRotation() != object.getRotation()
					|| otherDoor.getType() != object.getType()
					|| !otherDoor.getDefinitions().name.equalsIgnoreCase(object
							.getDefinitions().name)) {
				otherDoor = World.getObject(new WorldTile(object.getX() + 1,
						object.getY(), object.getPlane()), object.getType());
				if (otherDoor == null
						|| otherDoor.getRotation() != object.getRotation()
						|| otherDoor.getType() != object.getType()
						|| !otherDoor.getDefinitions().name
								.equalsIgnoreCase(object.getDefinitions().name))
					return false;
				right = false;
			}
			WorldObject openedDoor1 = new WorldObject(object.getId(),
					object.getType(), object.getRotation() + 1, object.getX(),
					object.getY(), object.getPlane());
			WorldObject openedDoor2 = new WorldObject(otherDoor.getId(),
					otherDoor.getType(), otherDoor.getRotation() + 1,
					otherDoor.getX(), otherDoor.getY(), otherDoor.getPlane());
			if (right) {
				openedDoor1.moveLocation(0, 1, 0);
				openedDoor1.setRotation(0);
				openedDoor2.moveLocation(0, 1, 0);
			} else {
				openedDoor1.moveLocation(0, 1, 0);
				openedDoor2.setRotation(0);
				openedDoor2.moveLocation(0, 1, 0);
			}
			if (World.removeTemporaryObject(object, 60000, true)
					&& World.removeTemporaryObject(otherDoor, 60000, true)) {
				player.faceObject(openedDoor1);
				World.spawnTemporaryObject(openedDoor1, 60000, true);
				World.spawnTemporaryObject(openedDoor2, 60000, true);
				return true;
			}
		}
		return false;
	}

	public static boolean handleDoor(Player player, WorldObject object,
			long timer) {
		if (World.isSpawnedObject(object))
			return false;
		WorldObject openedDoor = new WorldObject(object.getId(),
				object.getType(), object.getRotation() + 1, object.getX(),
				object.getY(), object.getPlane());
		if (object.getRotation() == 0)
			openedDoor.moveLocation(-1, 0, 0);
		else if (object.getRotation() == 1)
			openedDoor.moveLocation(0, 1, 0);
		else if (object.getRotation() == 2)
			openedDoor.moveLocation(1, 0, 0);
		else if (object.getRotation() == 3)
			openedDoor.moveLocation(0, -1, 0);
		if (World.removeTemporaryObject(object, timer, true)) {
			player.faceObject(openedDoor);
			World.spawnTemporaryObject(openedDoor, timer, true);
			return true;
		}
		return false;
	}

	private static boolean handleDoor(Player player, WorldObject object) {
		return handleDoor(player, object, 60000);
	}

	private static boolean handleStaircases(Player player, WorldObject object,
			int optionId) {
		String option = object.getDefinitions().getOption(optionId);
		if (option.equalsIgnoreCase("Climb-up")) {
			if (player.getPlane() == 3)
				return false;
			player.useStairs(-1, new WorldTile(player.getX(), player.getY(),
					player.getPlane() + 1), 0, 1);
		} else if (option.equalsIgnoreCase("Climb-down")) {
			if (player.getPlane() == 0)
				return false;
			player.useStairs(-1, new WorldTile(player.getX(), player.getY(),
					player.getPlane() - 1), 0, 1);
		} else if (option.equalsIgnoreCase("Climb")) {
			if (player.getPlane() == 3 || player.getPlane() == 0)
				return false;
			player.getDialogueManager().startDialogue(
					"ClimbNoEmoteStairs",
					new WorldTile(player.getX(), player.getY(), player
							.getPlane() + 1),
					new WorldTile(player.getX(), player.getY(), player
							.getPlane() - 1), "Go up the stairs.",
					"Go down the stairs.");
		} else
			return false;
		return false;
	}

	private static boolean handleLadder(Player player, WorldObject object,
			int optionId) {
		String option = object.getDefinitions().getOption(optionId);
		if (option.equalsIgnoreCase("Climb-up")) {
			if (player.getPlane() == 3)
				return false;
			player.useStairs(828, new WorldTile(player.getX(), player.getY(),
					player.getPlane() + 1), 1, 2);
		} else if (option.equalsIgnoreCase("Climb-down")) {
			if (player.getPlane() == 0)
				return false;
			player.useStairs(828, new WorldTile(player.getX(), player.getY(),
					player.getPlane() - 1), 1, 2);
		} else if (option.equalsIgnoreCase("Climb")) {
			if (player.getPlane() == 3 || player.getPlane() == 0)
				return false;
			player.getDialogueManager().startDialogue(
					"ClimbEmoteStairs",
					new WorldTile(player.getX(), player.getY(), player
							.getPlane() + 1),
					new WorldTile(player.getX(), player.getY(), player
							.getPlane() - 1), "Climb up the ladder.",
					"Climb down the ladder.", 828);
		} else
			return false;
		return true;
	}

	public static void handleItemOnObject(final Player player,
			final WorldObject object, final int interfaceId, final Item item) {
		final int itemId = item.getId();
		final ObjectDefinitions objectDef = object.getDefinitions();
		player.setCoordsEvent(new CoordsEvent(object, new Runnable() {
			@Override
			public void run() {
				player.faceObject(object);
				if (itemId == 1438 && object.getId() == 2452) {
					Runecrafting.enterAirAltar(player);
				} else if (object.getId() == 13193) {
					Bones bone = BonesOnAltar.isGood(item);
					if (bone != null) {
						player.getDialogueManager().startDialogue("PrayerD",
								bone, object);
						return;
					} else {
						player.getPackets().sendGameMessage(
								"Nothing interesting happens.");
						return;
					}
				} else if (itemId == 1513 && (object.getId() == 38453)) {
					UnlitBeacon.logstoOffer.RunBeacon(player, item);
				} else if (itemId == 1511 && (object.getId() == 38453)) {
					UnlitBeacon.logstoOffer.RunBeacon(player, item);
				} else if (itemId == 1515 && (object.getId() == 38453)) {
					UnlitBeacon.logstoOffer.RunBeacon(player, item);
				} else if (itemId == 1517 && (object.getId() == 38453)) {
					UnlitBeacon.logstoOffer.RunBeacon(player, item);
				} else if (itemId == 1518 && (object.getId() == 38453)) {
					UnlitBeacon.logstoOffer.RunBeacon(player, item);
				} else if (itemId == 1521 && (object.getId() == 38453)) {
					UnlitBeacon.logstoOffer.RunBeacon(player, item);
				} else if (itemId == 573 && object.getId() == 2152) {
					if (player.getInventory().getFreeSlots() < 1) {
						RCObelisks.orbstoOffer.RunObelisk(player, item);
						return;
					} else {
						player.sm("You don't have enough space to start this.");
						return;
					}
				} else if (object.getId() == 67968) {
					Sandstone sands = RedSandStone.isGood(item);
					if (sands != null) {
						player.getDialogueManager().startDialogue("SandD",
								sands, object);
						return;
					} else {
						player.getPackets().sendGameMessage(
								"Nothing interesting happens.");
						return;
					}
				} else if (itemId == 1440 && object.getId() == 2455) {
					Runecrafting.enterEarthAltar(player);
				} else if (itemId == 1442 && object.getId() == 2456) {
					Runecrafting.enterFireAltar(player);
				} else if (itemId == 1444 && object.getId() == 2454) {
					Runecrafting.enterWaterAltar(player);
				} else if (itemId == 1446 && object.getId() == 2457) {
					Runecrafting.enterBodyAltar(player);
				} else if (itemId == 1448 && object.getId() == 2453) {
					Runecrafting.enterMindAltar(player);
				} else if (object.getId() == 733 || object.getId() == 64729) {
					player.setNextAnimation(new Animation(PlayerCombat
							.getWeaponAttackEmote(-1, 0)));
					slashWeb(player, object);
					/**
					 * 
					 * Multicannon loading.
					 * 
					 */

				} else if (itemId == 2 && object.getId() == 6) {
					player.getDwarfCannon().loadDwarfCannon(object);
				} else if (itemId == 2 && object.getId() == 29406) {
					player.getGoldDwarfCannon().loadGoldDwarfCannon(object);
				} else if (itemId == 2 && object.getId() == 29408) {
					player.getRoyaleDwarfCannon().loadRoyaleDwarfCannon(object);

					/**
					 * Amrour Repair Stand
					 */

				} else if (itemId == 20138 && object.getId() == 13715) {
					player.getDialogueManager()
							.startDialogue("BrokenTorvaHelm");
				} else if (itemId == 20142 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue(
							"BrokenTorvaPlatebody");
				} else if (itemId == 20146 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue(
							"BrokenTorvaPlatelegs");
				} else if (itemId == 20162 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue(
							"BrokenVirtusMask");
				} else if (itemId == 20166 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue(
							"BrokenVirtusRobeTop");
				} else if (itemId == 20170 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue(
							"BrokenVirtusRobeLegs");
				} else if (itemId == 20150 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue(
							"BrokenPernixCowl");
				} else if (itemId == 20154 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue(
							"BrokenPernixBody");
				} else if (itemId == 20158 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue(
							"BrokenPernixChaps");
				} else if (itemId == 13889 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue(
							"DegVestaChainbody");
				} else if (itemId == 13895 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue(
							"DegVestaPlateskirt");
				} else if (itemId == 13901 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue(
							"DegVestaLongsword");
				} else if (itemId == 13907 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue("DegVestaSpear");
				} else if (itemId == 13886 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue(
							"DegStatiusPlatebody");
				} else if (itemId == 13892 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue(
							"DegStatiusPlatelegs");
				} else if (itemId == 13898 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue(
							"DegStatiusFullHelm");
				} else if (itemId == 13904 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue(
							"DegStatiusWarHammer");
				} else if (itemId == 13878 && object.getId() == 13715) {
					player.getDialogueManager()
							.startDialogue("DegMorriganCoif");
				} else if (itemId == 13872 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue(
							"DegMorriganLeatherBody");
				} else if (itemId == 13875 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue(
							"DegMorriganLeatherChaps");
				} else if (itemId == 13866 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue("DegZurielHood");
				} else if (itemId == 13863 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue(
							"DegZurielRobeBottom");
				} else if (itemId == 13860 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue(
							"DegZurielRobeTop");
				} else if (itemId == 13869 && object.getId() == 13715) {
					player.getDialogueManager().startDialogue("DegZurielStaff");
				} else if (itemId == 1919 && object.getId() == 13568) {
					player.getInventory().deleteItem(1919, 1);
					player.getInventory().addItem(1917, 1);
				} else if (itemId == 1919 && object.getId() == 13569) {
					player.getInventory().deleteItem(1919, 1);
					player.getInventory().addItem(5763, 1);
				} else if (itemId == 1919 && object.getId() == 13570) {
					player.getInventory().deleteItem(1919, 1);
					player.getInventory().addItem(1905, 1);
				} else if (itemId == 1919 && object.getId() == 13571) {
					player.getInventory().deleteItem(1919, 1);
					player.getInventory().addItem(1909, 1);
				} else if (itemId == 1919 && object.getId() == 13572) {
					player.getInventory().deleteItem(1919, 1);
					player.getInventory().addItem(1911, 1);
				} else if (itemId == 1919 && object.getId() == 13573) {
					player.getInventory().deleteItem(1919, 1);
					player.getInventory().addItem(5755, 1);

					/**
					 * Farming
					 */

					// Falador
				} else if (Allotments.allotments.containsKey(itemId)
						&& player.getFaladorNorthAllotmentPatchRaked()
						&& object.getId() == 8550) {
					Farming.plantAllotmentSeed(player, itemId, object.getId());
				} else if (Allotments.allotments.containsKey(itemId)
						&& player.getFaladorSouthAllotmentPatchRaked()
						&& object.getId() == 8551) {
					Farming.plantAllotmentSeed(player, itemId, object.getId());
				} else if (Flowers.flowers.containsKey(itemId)
						&& player.getFaladorFlowerPatchRaked()
						&& object.getId() == 7847) {
					Farming.plantFlowerSeed(player, itemId, object.getId());

					// Catherby
				} else if (Allotments.allotments.containsKey(itemId)
						&& player.getCatherbyNorthAllotmentPatchRaked()
						&& object.getId() == 8552) {
					Farming.plantAllotmentSeed(player, itemId, object.getId());
				} else if (Allotments.allotments.containsKey(itemId)
						&& player.getCatherbySouthAllotmentPatchRaked()
						&& object.getId() == 8553) {
					Farming.plantAllotmentSeed(player, itemId, object.getId());
				} else if (Flowers.flowers.containsKey(itemId)
						&& player.getCatherbyFlowerPatchRaked()
						&& object.getId() == 7848) {
					Farming.plantFlowerSeed(player, itemId, object.getId());

					// Ardougne
				} else if (Allotments.allotments.containsKey(itemId)
						&& player.getArdougneNorthAllotmentPatchRaked()
						&& object.getId() == 8554) {
					Farming.plantAllotmentSeed(player, itemId, object.getId());
				} else if (Allotments.allotments.containsKey(itemId)
						&& player.getArdougneSouthAllotmentPatchRaked()
						&& object.getId() == 8555) {
					Farming.plantAllotmentSeed(player, itemId, object.getId());
				} else if (Flowers.flowers.containsKey(itemId)
						&& player.getArdougneFlowerPatchRaked()
						&& object.getId() == 7849) {
					Farming.plantFlowerSeed(player, itemId, object.getId());

					// Canifis
				} else if (Allotments.allotments.containsKey(itemId)
						&& player.getCanifisNorthAllotmentPatchRaked()
						&& object.getId() == 8556) {
					Farming.plantAllotmentSeed(player, itemId, object.getId());
				} else if (Allotments.allotments.containsKey(itemId)
						&& player.getCanifisSouthAllotmentPatchRaked()
						&& object.getId() == 8557) {
					Farming.plantAllotmentSeed(player, itemId, object.getId());
				} else if (Flowers.flowers.containsKey(itemId)
						&& player.getCanifisFlowerPatchRaked()
						&& object.getId() == 7850) {
					Farming.plantFlowerSeed(player, itemId, object.getId());

					// Lumbridge
				} else if (Trees.trees.containsKey(itemId)
						&& player.getLummyTreePatchRaked()
						&& object.getId() == 8391) {
					Farming.plantTreeSapling(player, itemId, object.getId());

					// Varrock
				} else if (Trees.trees.containsKey(itemId)
						&& player.getVarrockTreePatchRaked()
						&& object.getId() == 8390) {
					Farming.plantTreeSapling(player, itemId, object.getId());

					// Falador
				} else if (Trees.trees.containsKey(itemId)
						&& player.getFaladorTreePatchRaked()
						&& object.getId() == 8389) {
					Farming.plantTreeSapling(player, itemId, object.getId());

					// Taverly
				} else if (Trees.trees.containsKey(itemId)
						&& player.getTaverlyTreePatchRaked()
						&& object.getId() == 8388) {
					Farming.plantTreeSapling(player, itemId, object.getId());

				} else if (object.getId() == 48803 && itemId == 954) {
					if (player.isKalphiteLairSetted())
						return;
					player.getInventory().deleteItem(954, 1);
					player.setKalphiteLair();
				} else if (object.getId() == 48802 && itemId == 954) {
					if (player.isKalphiteLairEntranceSetted())
						return;
					player.getInventory().deleteItem(954, 1);
					player.setKalphiteLairEntrance();
				} else if (object.getId() == 15621) {
					WGuildControler.handleItemOnObject(player, object, item);
				} else {
					switch (objectDef.name.toLowerCase()) {
					case "anvil":
						ForgingBar bar = ForgingBar.forId(itemId);
						if (bar != null)
							ForgingInterface.sendSmithingInterface(player, bar);
						break;
					case "fire":
						if (objectDef.containsOption(4, "Add-logs")
								&& Bonfire.addLog(player, object, item))
							return;
					case "range":
					case "cooking range":
					case "stove":
						Cookables cook = Cooking.isCookingSkill(item);
						if (cook != null) {
							player.getDialogueManager().startDialogue(
									"CookingD", cook, object);
							return;
						}
						player.getDialogueManager()
								.startDialogue(
										"SimpleMessage",
										"You can't cook that on a "
												+ (objectDef.name
														.equals("Fire") ? "fire"
														: "range") + ".");
						break;
					}
					if (Settings.DEBUG)
						System.out.println("Item on object: " + object.getId());
				}
			}
		}, objectDef.getSizeX(), objectDef.getSizeY(), object.getRotation()));
	}
}
